Install MySQL and Ubuntu tumysql
1. Verify that MySQL is installed on the original host:Run the sudo netstat-tap | grep mysql command to check whether the MySQL port exists. If sudo is not added, the execution fails because of the permission:
$ netstat -tap | grep mysql
Ii. Install MySQL:After confirming that MySQL is not installed on the host, run the command sudo apt-get install mysql-server mysql-client for online installation:
$ sudo apt-get install mysql-server mysql-client
During the installation process, you will be prompted to enter Yes, and then the root password setting interface will pop up. Here, you can set a root password for login to mysql users, you can run mysqladmin-u root-p password to change the password as needed. Of course, you must enter the original password at that time.
$ mysqladmin -u root -p password
Iii. Start MySQL:By default, the MySQL service is started when Ubuntu is started. You can also run the following command to start and close MySQL:
# Start MySQL
$ sudo service mysql start
# Disabling MySQL
$ sudo service mysql stop
# Restart MySQL
$ sudo service mysql restart
# Other commands:
$ sudo /etc/init.d/mysql start
$ sudo /etc/init.d/mysql stop
$ sudo /etc/init.d/mysql restart
Then, run the following command again to check whether MySQL has been started:
$ netstat -tap | grep mysql
MySQL listening on localhost indicates that MySQL has been started.
4. log on to MySQL:Use the command line mysql-u root-p to log on to MySQL:
$ mysql -u root -p
P.S. I recently tried to install MySQL on Ubuntu for your reference. The configuration issue will be resolved later.