Solution to the error of MySQL: unrecognized service (CentOS)

service mysql start Error, mysql won’t start, the solution for mysql: unrecognized service error is as follows.

[[email protected] ~]# service mysql start
mysql: unrecognized service
[[email protected] ~]# service mysql restart
mysql: unrecognized service

[[email protected] ~]# rpm -q mysql The query found that mysql is installed properly
mysql-5.1.52-jason.1

[[email protected] ~]# /etc/rc.d/init.d/mysqld start Start directly with no problem
Starting mysqld: [ OK ]

[[email protected] ~]# ls /etc/rc.d/init.d/mysqld -l
-rwxr-xr-x 1 root root 5509 Dec 18 02:31 /etc/rc.d/init.d/mysqld

[[email protected] ~]# chkconfig mysqld on Set mysql to start on boot

[[email protected] ~]# chmod 755 /etc/rc.d/init.d/mysqld Modify mysqld execute permissions

[[email protected] ~]# service mysqld start Get it done
Starting mysqld: [ OK ]
[[email protected] ~]# service mysqld start
Starting mysqld: [ OK ]
[[email protected] ~]# service mysqld status
mysqld (pid 9487) is running…

If the above does not work, you can also refer to this.

Solution to connect to Mysql prompting Can’t connect to local MySQL server through socket

The main change is: my.cnf file [mysql socket file location is set in /etc/my.cnf]

[mysqld]
datadir=/storage/db/mysql
socket=/storage/db/mysql/mysql.sock
 
[mysql]
socket=/storage/db/mysql/mysql.sock
 
[mysqldump]
socket=/storage/db/mysql/mysql.sock
 
[mysqladmin]
socket=/storage/db/mysql/mysql.sock

I modified this problem first and implemented it according to the first method

attachment: modify MySQL default password (default is empty)

Modify MySQL default account password

After installing the MySQL database, you must modify the default account password of the database to ensure the security of the database

#mysql

mysql> usemysql;

Databasechanged

mysql> selectuser,password,hostfromuser;

+——-+——————————————-+—————–+

|user|password|host|

+——-+——————————————-+—————–+

|root||localhost|

|root||email-admin|

|root||127.0.0.1|

|root||::1|

localhost|

email-admin|

|root||%|

Check the database and find that the default root account and empty account are not set up password

Change the password for the root user

mysql>updateusersetpassword=PASSWORD(‘yourpassword’) whereuser=’root’;

QueryOK,5rowsaffected(0.00sec)

Rowsmatched:5Changed:5Warnings:0

Delete empty account

mysql>deletefromuserwhereuser=”;

QueryOK,2rowsaffected(0.00sec)

mysql>selectuser,password,hostfromuser;

+——-+——————————————-+—————–+

|user|password|host|

+——-+——————————————-+—————–+

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|localhost|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|email-admin|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|127.0.0.1|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|::1|

|root|*5A85E100F2A0D4AD5805DD6E3331937747369E5B|%|

Finally, refresh the cache to ensure that the new password is immediately available

mysql>flush privileges;

QueryOK,0rowsaffected(0.01sec)

 

Similar Posts: