首页 / 数据库 / MySQL / CentOS 6.2下如何使用YUM安装MySQL
CentOS 6.2下如何使用YUM安装MySQL2014-10-28用yum安装MySql打入如下命令:[root@mysql ~]# yum -y install mysql-server //自动从网上搜索资源并自动下载安装[root@mysql ~]# chkconfig mysqld on //设置开机启动MySql服务检查是否为开机启动打入命令:[root@mysql ~]# chkconfig –list看到:mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off 即表示已设置为开机启动,2、3、4、5为on启动MySql服务/etc/rc.d/init.d/mysqld start //从文件启动MySql服务service mysqld start //以服务名方式启动MySql初始化环境设置(一)设置MySQL的root用户设置密码,因为MySQL被安装时,它的root用户时没有设置密码的。[root@mysql ~]# mysql -u rootWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 2Server version: 5.1.61 Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type "help;" or "h" for help. Type "c" to clear the current input statement.mysql>2. 如上,默认是不需要密码就可以进入数据库操作,下面查看MySQL数据库用户信息MySql初始化环境设置(二)打入命令:select user,host,password from mysql.user; //可以看到密码都为空+------+-----------+----------+| user | host | password |+------+-----------+----------+| root | localhost | || root | mysql | || root | 127.0.0.1 | || | localhost | |本栏目更多精彩内容:http://www.bianceng.cn/database/MySQL/| | mysql | |+------+-----------+----------+5 rows in set (0.00 sec)set password for root@localhost=password(‘123456789’); //设置root用户密码为123456789MySql初始化环境设置(三)打入命令:select user,host,password from mysql.user; //查看刚设置的密码,可以看到密码已经经过加密处理+------+-----------+-------------------------------------------+| user | host | password |+------+-----------+-------------------------------------------+| root | localhost | *CC67043C7BCFF5EEA5566BD9B1F3C74FD9A5CF5D || root | mysql | || root | 127.0.0.1 | || | localhost | || | mysql | |+------+-----------+-------------------------------------------+5 rows in set (0.00 sec)打入exit命令退出数据库连接,测试root密码是否生效