MySQL问题-Unit mysqld.service could not be found.

  • Requirements: yesterday decided to go to the server development team, but not because I configured before, so after the restart the server, mysql this service is lost, how would not be able to start yesterday afternoon, servers and personal collapse, so this problem now do, the next recorder
  • Mysqld service can not find
    the specific command
service mysqld status
systemctl status mysqld

result

Unit mysqld.service could not be found.

According to the result of an error from Internet search and found that there is no mysqld command /etc/init.d

  • Specific solutions
  1. Find mysql.server file, which is said to mysqld file with exactly the same, just a different file name
[root@ldy ~]$ find / -name mysql.server
/usr/local/mysql-8.0.13/support-files/mysql.server

  1. Mysql.server copy files to the /etc/init.d/ directory, rename mysqld
[root@ldy ~]$ cp /usr/local/mysql-8.0.13/support-files/mysql.server /etc/init.d/mysqld

  1. View mysqld status status
[root@ldy ~]$ service mysqld status
/etc/init.d/mysqld: line 239: my_print_defaults: command not found

Reported above this mistake
I did not give up, things start at
4. Start Mysqld, view the error

[root@ldy ~]$ service mysqld start
/etc/init.d/mysqld: line 239: my_print_defaults: command not found
/etc/init.d/mysqld: line 259: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

This time I found all this in mysqld command inside of mistakes, but at least I know, mysql installation path is not this

 /usr/local/mysql

But this

[lidengyin@ldy ~]$ cd /usr/local/mysql-8.0.13/
[lidengyin@ldy mysql-8.0.13]$ pwd
/usr/local/mysql-8.0.13

  1. Enter mysqld attempt to modify the basic path
[root@ldy etc]$ vim -n /etc/init.d/mysqld 

Specific changes being given path is the correct path
error path

 66   basedir=/usr/local/mysql
 67   bindir=/usr/local/mysql/bin
 68   if test -z "$datadir"
 69   then
 70     datadir=/usr/local/mysql/data
 71   fi
 72   sbindir=/usr/local/mysql/bin
 73   libexecdir=/usr/local/mysql/bin

Correct path

 66   basedir=/usr/local/mysql-8.0.13
 67   bindir=/usr/local/mysql-8.0.13/bin
 68   if test -z "$datadir"
 69   then
 70     datadir=/usr/local/mysql-8.0.13/data
 71   fi
 72   sbindir=/usr/local/mysql-8.0.13/bin
 73   libexecdir=/usr/local/mysql-8.0.13/bin

  1. View the status and start again
[root@ldy etc]$ service mysqld status
 ERROR! MySQL is not running
[root@ldy etc]$ service mysqld start
Starting MySQL.Logging to '/usr/local/mysql-8.0.13/data/izwz9f5dsyzzjf3wit8o3cz.err'.
... SUCCESS! 

7. Enter the mysql error

[root@ldy etc]$ mysql -uroot -p
-bash: mysql: command not found

Did not find the command, use absolute paths


[root@ldy etc]$ /usr/local/mysql-8.0.13/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit

Success
8. Add the environment variable to add a soft link to
the default command looks at / usr / bin, if this command does not exist in this directory, we need to do a mapped to / usr / bin directory, which is equivalent to link files

[root@ldy etc]$ ln -s /usr/local/mysql-8.0.13/bin/mysql /usr/bin
[root@ldy etc]$ whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql
[root@ldy etc]$ ln -s /usr/local/mysql-8.0.13/bin/mysql /usr/local/bin
[root@ldy etc]$ whereis mysql
mysql: /usr/bin/mysql /usr/lib64/mysql /usr/local/bin/mysql

Enter mysql will complain

[root@ldy etc]$ mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@ldy etc]$ mysql -version
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

But already successfully landed

[root@ldy etc]$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
  1. Solve Access denied for user 'root' @ 'localhost' (using password: YES) issues
    this difficult to me that I should not have the my.ini, because I can
mysql -uroot -p

Successfully entered, but a separate mysql command fails, who knows welcome message.

Published 105 original articles · won praise 51 · views 8772

Guess you like

Origin blog.csdn.net/weixin_43404791/article/details/105174074