[root@Cacti ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
#上述原因是没有启动mysql服务
[root@Cacti ~]# /etc/init.d/mysqld start
正在启动 mysqld: [确定]
[root@Cacti ~]# chkconfig
mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[root@Cacti ~]# chkconfig --level 345 mysqld on #设置开机自动启动mysql服务
[root@Cacti ~]# chkconfig --list mysqld
#通过IP连接数据库服务
[root@Cacti ~]# mysql -h ip -uroot -p