openSUSE Leap 42.1 的 mysql 打不开

之前的版本是能打开的,然后提示符是 mariadb,现在却打不开了。systemctl 命令也试了。求助

来自我的 MI 4LTE 上的 Tapatalk

mysql

systemctl status -l mysql

贴一下这两条命令返回的结果,不然谁知道什么原因。

!](http://uploads.tapatalk-cdn.com/20160224/45bf4ccf41ef47582598f2e0851c2a36.jpg)

来自我的 MI 4LTE 上的 Tapatalk

@CyberRanger

你的 mysql 没有启动,猜测一下原因,应该是 mysql 升级时,原来的数据在升级迁移时出现了问题,如果你的 mysql 里没有什么重要的数据话,一个简单的解决方法是清空 mysql 里的所有数据,删除 /var/lib/mysql 目录下的所有文件,杀掉所有 mysql 的进程,然后 systemctl try-restart mysql.service 试试,看看能不能启动。

我上网不方便,机器在家。只能晚上回家试试。所以不能及时回复,还望见谅,非常感谢。

来自我的 MI 4LTE 上的 Tapatalk

我是全新安装的 Leap42.1 mysql 也打不开
运行是这个问题

mysql -u root -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock' (2 "No such file or directory")

尝试重新安装一下

sudo mysql_install_db

按照流程来也不行,试着看了一下

# rasin at linux.suse in /var/lib/mysql [9:35:55]
$ ps aux | grep mysql
root     15129  0.0  0.0  79348  5760 pts/2    S+   09:30   0:00 sudo mysql_secure_installation
root     15130  0.0  0.0  13208  3004 pts/2    S+   09:30   0:00 /bin/sh /usr/bin/mysql_secure_installation
rasin    16816  0.0  0.0  10524  1524 pts/4    S+   09:37   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn mysql
# rasin at linux.suse in /var/run [9:39:39]
$ systemctl status -l mysql
mysql.service - MySQL server
   Loaded: loaded (/usr/lib/systemd/system/mysql.service; disabled)
   Active: inactive (dead)

是死掉的状态……
按照@恋衣之曲 大大的说法删除数据库文件夹

# rasin at linux.suse in /var/run [9:42:42]
$ sudo rm -r /var/lib/mysql
rm: 无法删除"/var/lib/mysql": 设备或资源忙

现在也不知道要怎么解决了……求助

好吧竟然奇怪地解决了……

# rasin at linux.suse in ~ [9:54:57]
$ sudo zypper in mariadb-tools mariadb mariadb-client
 完毕]

然后以 root 执行 rcmysql start

# rasin at linux.suse in ~ [9:55:24]
$ sudo rcmysql start

走安全安装流程

# rasin at linux.suse in ~ [9:56:03]
$ sudo /usr/bin/mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

最后启动服务项就好了

# rasin at linux.suse in ~ [9:56:49]
$ sudo systemctl enable mysql.service 

# rasin at linux.suse in ~ [9:57:12]
$ sudo systemctl start mysql.service 

# rasin at linux.suse in ~ [9:57:35]
$ sudo mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 10.0.22-MariaDB openSUSE package

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

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

MariaDB (none)]> quit
Bye

我一定是流程没走对……