Ubuntu 18.04 install mysql 5.7.23
It was very smooth to install MySQL in Ubuntu 16.04. this time when installing MySQL 5.7.23 in Ubuntu 18.04, we encountered some pits and struggled for a long time. Here is a record.
1. Install the database
Sudo apt-get install mysql-server
By default, related clients such as mysql-client will be installed when mysql-server is installed.
two。 There will be problems when logging in directly at this time.
This is a pit, and later found that the use of root permissions to log in will be successful.
Well, since you can only log in under the authority of the root user, let's take a look at what key information exists in mysql.user.
First look at the structure of the user table:
Mysql > show columns from user
There are mainly these items:
Host User authentication_string (this is the encrypted password) plugin
Take a look at these key pieces of data in the table:
As you can see, the root password is still empty, and plugin is obviously different from others. After consulting the relevant information, we found that this is the problem that ordinary users can not log in.
3. Resolve the problem and change the password
Mysql > update user set authentication_string=PASSWORD ("123456"), plugin= "mysql_native_password" where user= "root"; mysql > FLUSH PRIVILEGES; # exit restart MySQL service mysql > exit;fknight@v310:~$ service mysql restart
After update:
You can now log in to the MySQL database using the root account name with normal user privileges. Workbench/Navciat can also connect to the database for normal use.
Summary:
# install MySQL and Workbranchfknight@v310:~$ sudo apt-get install mysql-server mysql-client mysql-workbench # connect data with root authority, initial password is empty fknight@v310:~$ sudo mysql- u root-p # modify plugin to enable ordinary users to log in using mysql's root user, and change root password mysql > update user set authentication_string=PASSWORD ("123456"), plugin= "mysql_native_password" where user= "root"; # exit and restart MySQL service mysql > exit Fknight@v310:~$ service mysql restart
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.