First, install and delete
install
sudo apt-get update # update the source
sudo apt-get install mysql-server # install mysql
Delete
sudo APT-GET autoremove MySQL - \ * --purge
(pop-up boxes, whether to delete the data (deleted after data is gone, attention backup) Select yes.)
Second, using a
1. landing mysql
note without sudo user will be denied access
syntax: mysql -u <username> -p <password> -h <address / domain name> -P <port>
using the default root root (no password): mysql -u root -h 127.0.0.1
2. User Management
- user query
// respectively password, user name, access geology, type the password plug
the SELECT authentication_string, the User, Host, plugin from the mysql.user;
- change the root password
update user set authentication_string = password ( ' XXX '), password_expired =' N ', password_last_changed = now () = the mysql.user WHERE' root ';
- root authorized user remote login,% represents not the IP
the GRANT ALL PRIVILEGES the ON the TO * *.' root '@' % 'IDENTIFIED BY' xxx ';
- refresh permission, be sure to perform
flush privileges;
3. Set the mysql remote access to
a. Edit the file
// note the path, and different legacy
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
find bind-address, comment out (#) or specify any ip or 0.0 .0.0 follows:
# = the bind-address 127.0.0.1
the bind-address = 0.0.0.0
Save and exit the editor
b. Restart the mysql service
service mysql restart
Third, log in using the following command
mysql -u root -p xxx -h127.0.0.1 -P3306