1MySQL change the password
update mysql.user set password=password('newpassword') where user='root' #Change
the newpassword character in password() to your own password.
For example change it to 123456:
update mysql.user set password=password ('123456') where user='root'
2 mysql is set as a network database, that is, the
first method of remote access to mysql: directly enter the account name and password to enter the database. Find the user table of the mysql database, update the root user's Host directly, change Host: localhost, user: root to Host: %, user: root
and then mysql> flush privileges; (run this sentence to take effect, or restart MySQL). Because the permissions of mysql are all in the cache, it needs to be refreshed.
After changing to %, any IP can access the mysql server, which is very insecure. You can replace the % will with an IP address, that is, only allow access from that IP address.
The second method: directly enter the account name and password to enter the database.
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;
mysql> flush privileges;
The root user's authority is too large. It is recommended to create a new user and give it some authority to a database
------------------------------- ---------------
I used the first method.
MariaDB [mysql]> update user set host='%' where host='localhost' and user='root';
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [mysql] > flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> select * from user;
The database server can now be connected to the MySQL client.
mysql is set as a network database, that is, remote access to mysql, modify the root password
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326943880&siteId=291194637
Recommended
Ranking