text mysqlсброспароля

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text mysqlсброспароля相关的知识,希望对你有一定的参考价值。

Setting MySQL Root Password
To reset MySQL root password, logon to the server and run the commands below to stop MySQL database service

sudo /etc/init.d/mysql stop

Then run the commands below to create a new mysqld directory

sudo mkdir /var/run/mysqld/

and give mysql user access to it.

sudo chown mysql /var/run/mysqld/

After that, run the commands below to start MySQL in safe mode by bypassing the standard authentication process..

sudo mysqld_safe --skip-grant-tables &

You should see something like this… you may have to press the Enter key…

richard@ubuntu1710:~$ 2017-12-25T16:49:30.551520Z mysqld_safe Logging to syslog.
2017-12-25T16:49:30.554646Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-12-25T16:49:30.578079Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2017-12-25T16:49:32.568746Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

[1]+  Done                    sudo mysqld_safe --skip-grant-tables
Next, run the commands below to logon to the database server with the root account without typing a password

sudo mysql -u root

Then change to the mysql database by running the SQL command below

use mysql;

Finally, run the SQL statement below to change the root password

update user set authentication_string=PASSWORD("New_Passwore_Here") where User='root';

Save the change by running the commands below

flush privileges;
exit;
Finally, stop MySQL safe_mode and start MySQL default service

sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start



-----------------------------

Next, check which authentication method each of your MySQL user accounts use with the following command:

SELECT user,authentication_string,plugin,host FROM mysql.user;
Output
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             |                                           | auth_socket           | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)
In this example, you can see that the root user does in fact authenticate using the auth_socket plugin. To configure the root account to authenticate with a password, run the following ALTER USER command. Be sure to change password to a strong password of your choosing:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Then, run FLUSH PRIVILEGES which tells the server to reload the grant tables and put your new changes into effect:

FLUSH PRIVILEGES;
Check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the auth_socket plugin:

SELECT user,authentication_string,plugin,host FROM mysql.user;
Output
+------------------+-------------------------------------------+-----------------------+-----------+
| user             | authentication_string                     | plugin                | host      |
+------------------+-------------------------------------------+-----------------------+-----------+
| root             | *3636DACC8616D997782ADD0839F92C1571D6D78F | mysql_native_password | localhost |
| mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)
You can see in this example output that the root MySQL user now authenticates using a password. Once you confirm this on your own server, you can exit the MySQL shell:

以上是关于text mysqlсброспароля的主要内容,如果未能解决你的问题,请参考以下文章

php Функцияскачиванияфайла$ b $bПростоотправляемнаурлсобработчиком,передаваяссылкунафайл

text ДобавитьвыборкалендарякполюБитркис

javascript Фиксацияблокаприскролле

sql Задание1.ДолжновыполнятьсясиспользованиемMySQL(иприжеланиисPHP)Преобразоватьданныетаблицытакимоб

php Формаобратнойсвязи。 ПримернаосновеиспользованияплагинаAJAXSimply

javascript Оберткадляпервогослова