Configure Mysql on the cloud server

The first thing we have to do is to log in to mysql and enter service mysql status to see if the mysql service has been started.

 

 

The normal startup is like this, then log in to mysql, enter mysql -u root -p, and then it should print mysql command not find , this is because we did not configure the mysql service to the system environment variables,

 

Enter cd /usr/local/bin and then enter ln -fs /MYSQLPATH/bin/mysql mysql (here is the name you gave mysql, you can write mysql or mysqld, fill in your mysql installation path in MYSQLPATH )

 

Now enter mysql -u root -p and then enter the password to log in to mysql, but what is the password? There are instructions in the application details, sudo grep mysql_root_passwd /root/env.txt to save the initial password,

 

Seeing the mysql command window is successful, let's start to modify the root account password, first switch the database: use mysql Then we can enter update mysql.user set password=password('root') where user='root' ;

The password of the root account is changed to root. This can be set by yourself, or it can be set to be more complicated. After inputting, it will show that the password colmn does not exist, because mysql has updated this field and changed it to authentication_string

So we changed the statement to update mysql.user set authentication_string=password('root') where user='root' ; , and found that it still doesn't work after entering it. Is there an urge to smash the keyboard in anger, haha, hold on

This is because we do not have the permission to add, delete, or modify, just enter set sql_safe_updates=0; and we can modify the password successfully after entering the command to modify the password. Finally, we need to refresh the database permissions flush privileges;

 

At this point, mysql can be used. If you want to use database tools to connect, you need to give an account remote connection permission to enter:

 

.GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;  

Create the database, and then upload the project to the root directory of the website (ie /home/www/htdocs) We are done, enjoy your achievements!

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324476170&siteId=291194637