MySQL simple installation method:
1. sudo apt-get install mysql-server
2. apt-get install mysql-client
3. sudo apt-get install libmysqlclient-dev
During the installation process, you will be prompted to set a password or something. Be careful not to forget the settings. After the installation is complete, you can use the following command to check whether the installation is successful:
sudo netstat -tap | grep mysql
After checking through the above command, if you see that the mysql socket is in the listen state, the installation is successful.
To log in to the mysql database, use the following command:
mysql -u root -p
-u means to select the user name to log in, -p means the user password to log in, after entering the above command, you will be prompted to enter the password, at this time, you can log in to mysql by entering the password.
Then through show databases; you can view the current database.
We select the mysql database and proceed to the next step. Use the use mysql command to display the form of the current database: show tables;
If you run the command line: # mysql -uroot -p The following error message appears:
You need to start mysql, the command is as follows:
# service mysql start
Enter the command line again: # mysql -uroot -p The following error message appears:
The processing steps are as follows:
# service mysql stop
# usermod -d /var/lib/mysql/ mysql
# service mysql start
Then run # mysql -uroot -p again and everything works fine.
Check the version of mysql:
mysql> select version(); +-------------------------+ | version() | +-------------------------+ | 5.7.19-0ubuntu0.16.04.1 | +-------------------------+ 1 row in set (0.00 sec)