解决方案:其实mysql.sock是存在的,只是它不在/tmp目录下而已,默认情况下,mysql.sock在/var/lib/mysql/目录下,我们只需要创建一个软链接到/tmp目录下即可
1
[root@leaf mysql]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
这时再重复上面的操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@leaf mysql]# bin/mysqladmin version bin/mysqladmin Ver 8.42 Distrib 5.6.29, for linux-glibc2.5 on x86_64 Copyright (c) 2000, 2016, 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. Server version 5.6.29 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /tmp/mysql.sock Uptime: 6 min 36 sec Threads: 1 Questions: 2 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.005
成功了!然后我们再进行下面的操作热热身吧:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
[root@leaf mysql]# bin/mysqladmin -u root shutdown #通过mysqladmin关闭mysql服务 [root@leaf mysql]# bin/mysqld_safe --user=mysql & #启动mysql服务 #查看mysql数据库中默认存在的数据库 [root@leaf mysql]# bin/mysqlshow +--------------------+ | Databases | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ #查看mysql数据库(注意此mysql数据库是一个实体,与上面的统称不同)中的数据表 [root@leaf mysql]# bin/mysqlshow mysql Database: mysql +---------------------------+ | Tables | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | innodb_index_stats | | innodb_table_stats | | ndb_binlog_index | | plugin | | proc | | procs_priv | | proxies_priv | | servers | | slave_master_info | | slave_relay_log_info | | slave_worker_info | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+ 查看mysql数据库中的所有user表 [root@leaf mysql]# bin/mysql -e "SELECT User, Host, plugin FROM mysql.user" mysql +------+-----------+-----------------------+ | User | Host | plugin | +------+-----------+-----------------------+ | root | localhost | mysql_native_password | | root | leaf | mysql_native_password | | root | 127.0.0.1 | mysql_native_password | | root | ::1 | mysql_native_password | | | localhost | mysql_native_password | | | leaf | mysql_native_password | +------+-----------+-----------------------+
需要注意的是,上面的这些测试必须要在你已经启动了mysql服务的情况下才去进行操作。同时,如果想知道每一步的详细解释,可以参考官方文档:
准确来讲,MySQL是已经成功安装完成了!下面我们再做一些基础的优化,主要是从安全的角度去考虑。