简体   繁体   中英

MySQL Workbench on Linux

I installed MySQL on Ubuntu 16.04. I can login to MySQL shell by typing the command:

sudo mysql -u root

However, I also want to see the DB via MySQL Workbench. I installed it on my computer, and when I go to Database -> Connect to Database I get the following window:

在此处输入图片说明

When I click 'OK' I get the following dialog:

在此处输入图片说明

I checked 1 and 2. 3 I don't know how to check and as for 4, I don't know what is the password at all (I don't have to use it to login via the console).

Do you know how to resolve it?

Firstly never work with root on a server. Period it is a bad habit. So first things first would be to log into the command line and create a user that is the root equivalent and then use that user.

So use the command line and then execute the following steps:

   CREATE USER 'username'@'%' IDENTIFIED BY 'password';
   GRANT ALL PRIVILEGES ON *.* TO 'username'@'%'
   WITH GRANT OPTION;
   FLUSH PRIVILEGES;

This will create an administrative user called username. You can then use this account to log in. Get in the habit of doing this.

Use terminal login mysql

sudo mysql -u root

Initial root password

update user set password=PASSWORD(‘123456’) where User='root';

And then try workbench login again.

If you want to connect mysql service from any others host except localhost, you need set root host to %

mysql -u root –p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;   --check result,init value maybe 127.0.0.1 or localhost

I think that I found the problem. When I installed MySQL, I skipped the option to give a password to root user. Therefore, I decided to remove MySQL from my linux by using the command:

apt-get purge mysql mysql-server mysql-common mysql-client

and then re-install it by:

apt-get install mysql-server

This time, I gave a password to root user during the installation, and after the installation had been finished, I opened MySQL Workbench and used the password I gave during the installation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM