Skip to content

Instantly share code, notes, and snippets.

@javathought
Last active October 14, 2015 21:36
Show Gist options
  • Save javathought/2fb7913e21faa8c340a1 to your computer and use it in GitHub Desktop.
Save javathought/2fb7913e21faa8c340a1 to your computer and use it in GitHub Desktop.
# /etc/init.d/mysql stop
Shutting down MySQL..
# mysqld_safe --skip-grant-tables --skip-networking &
[1] 4983
# Starting mysqld daemon with databases from /var/lib/mysql
# mysql mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.21-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> update user set password=password('aaaaaaaa') where user="root" and host="localhost";
Query OK, 0 rows affected (0,00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> exit
Bye
# mysqladmin shutdown
STOPPING server from pid file /var/lib/mysql/debian.pid
030811 14:38:40 mysqld ended
[1]+ Done /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --skip-networking
# /etc/init.d/mysql start
Starting MySQL
# mysql -u root -p
====================================================================================================
If the GRANT ALL doesn't work, try:
Stop mysqld and restart it with the --skip-grant-tables option.
Connect to the mysqld server with just: mysql (i.e. no -p option, and username may not be required).
Issue the following commands in the mysql client:
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
FLUSH PRIVILEGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment