Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to start mysql in safe mode

Tags:

mysql

According to this question Access Denied for MYSQL ERROR 1045 I should be able to start MySQL in safe mode with

sudo mysqld_safe --skip-grant-tables

but this simply logs the following lines to STDOUT:

151116 17:46:46 mysqld_safe Logging to '/usr/local/var/mysql/MacBook-Pro.local.err'.
151116 17:46:46 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
151116 17:46:46 mysqld_safe mysqld from pid file /usr/local/var/mysql/MacBook-Pro.local.pid ended

and returns me to the command line. The error log quoted has the same last 2 lines output here. When I try and connect to MySQL I get:

mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
like image 883
Snowcrash Avatar asked Nov 16 '15 22:11

Snowcrash


People also ask

How do I start MySQL in safe mode?

mysqld_safe tries to start an executable named mysqld. To override the default behavior and specify explicitly the name of the server you want to run, specify a --mysqld or --mysqld-version option to mysqld_safe. You can also use --ledir to indicate the directory where mysqld_safe should look for the server.

How do I know if MySQL is running in safe mode?

Execute UPDATE query:Run the UPDATE command without the WHERE clause to check the safe update mode is working or not for the update operation. If the safe update mode is enabled, the error 1175 will be generated for the UPDATE query.

Can't start MySQL server?

Restart your OS. When restarted check if the MySQL service is no more present the Windows Services (search for services in windows). Be sure no services that use MySQL (application needing access to MySQL) are active. Resinstall MySQL and the service will be able to install itself again.


1 Answers

Just encountered exact same issue on mac. I was able to reset the root password with following steps.

mysqld --skip-grant-tables  # this will run mysql 
    
mysql -u root
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';

NOTE: Seems like newer version of mysql has error when running 'sudo mysqld_safe --skip-grant-tables'.

like image 142
ibaralf Avatar answered Sep 24 '22 14:09

ibaralf