In ubuntu, we often use the apt-get command plug-in. In fact, it has been updating the corresponding resource library. So far,
The latest version of mysql in the apt-get resource library is: mysql-5.7.29
Therefore, we can install mysql57 directly through the latest version of apt-get command, avoiding many troubles of manual installation;
This article will take you through the original installation process. If you are preparing to install mysql57 on the ubuntu system, congratulations, this article will definitely help you. If you encounter any trouble, leave a message below as soon as possible, and I will diagnose the problem in time.
dpkg --list|grep mysql
Uninstall mysql-common first
sudo apt-get remove mysql-common
Then execute:
sudo apt-get autoremove --purge mysql-server-5.0
Then continue to check with dpkg --list|grep mysql, uninstall whatever is left;
Two, install mysql
# Update apt-get, the latest resource library will be used after the update
sudo apt-get update
# Install MySQL:
sudo apt-get install mysql-server
# View MySQL version:
mysql -V
# Enter MySQL:
mysql -u root -p
# start up:
sudo service mysql start
# Reboot:
sudo service mysql restart
# shut down:
sudo service mysql stop
Ubuntu16-Ubuntu18 installs mysql5.7 without prompt for password, mysql default password is empty; just log in directly;
If you use the mysql -uroot -p command to connect to mysql, an error is reported
ERROR 1045(28000): Access denied for user ‘root’@'localhost’
Now you can modify the default password of root:
show databases;
use mysql;
update user set authentication_string=PASSWORD("123456") where user='root';
update user set plugin="mysql_native_password";
flush privileges;
exit;
Enter the mysql command line and enter: show variables like'character%';
We need to adjust the database and server to utf8;
First we find the mysqld.cnf file: find / -name mysqld.cnf
Modify the content of mysqld.cnf: just add it under the corresponding label (as shown below), **if there is no [mysql] label, add **;
[ mysql]default-character-set=utf8
[ mysqld]
character_set_server=utf8
collation_server=utf8_general_ci
Restart mysql after saving; service mysql restart; log in to the mysql command line again after restart
Type show variables like'character%';
The following figure shows that the database configuration is complete;
Recommended Posts