1.检查是否已经有mysql
rpm -qa |grep -i mysql
MySQL-python-1.2.3-0.3.c1.1.el6.x86_64
mysql-libs-5.1.71-1.el6.x86_64
mod_auth_mysql-3.0.0-11.el6_0.1.x86_64
mysql-server-5.1.71-1.el6.x86_64
mysql-bench-5.1.71-1.el6.x86_64
qt-mysql-4.6.2-26.el6_4.x86_64
libdbi-dbd-mysql-0.8.3-5.1.el6.x86_64
mysql-devel-5.1.71-1.el6.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
mysql-5.1.71-1.el6.x86_64
dovecot-mysql-2.0.9-7.el6.x86_64
qt3-MySQL-3.3.8b-30.el6.x86_64
mysql-connector-java-5.1.17-6.el6.noarch
mysql-test-5.1.71-1.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
rsyslog-mysql-5.8.10-8.el6.x86_64
php-mysql-5.3.3-26.el6.x86_64
说明之前已经有了。
然后:
mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket 'arb/mysql/mysql.sock' (2)
service mysqld start
Starting mysqld: [FAILED]
# 查看mysql服务启动选项的设置
chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
whereis mysql
mysql: /usr/bin/mysql /usrb64/mysql /usr/include/mysql /usr/mysql /usr/man/man1/mysql.1.gz
which mysql
/usr/bin/mysql
检查/etc/my.cnf
vim /etc/my.cnf
发现已经正确连接了。
切换到root账户下
su
service mysqld start
..
OK
mysql -u root -p
初始时root的密码是没有的
2.chkconfig mysql 服务
# 删除mysqld服务
chkconfig --del mysqld
ps
chkconfig 主要用来更新(启动或停止)和查询系统服务的运行级信息。
chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。
# 增加mysqld服务
chkconfig --add mysqld
chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
# 设置开机自动启动
chkconfig mysqld on
chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off