CentOS5.4(64bit)下安装配置Cacti----Mysql安装配置(yum安装)
我要使用的系统版本为:# cat /etc/issue
CentOS release 5.4 (Final)
Kernel \r on an \m 我使用的是yum安装,就不要先去下载软件了,直接用yum安装时,就会自动下载了。
(使用yum时,还出现了一点小插曲,不过也正因为如此才知道了更多的东西吧)。
首先是安装Mysql
1,确认系统中是否已安装Mysql。(CentOS好像自带有Mysql的)
# rpm -qa |grep mysql
mysql-5.0.77-3.el5
果然已经安装有了,但和我要的版本不一致,升级或卸载后重新安装。
直接更新就是了。
# yum update mysql
2,同样的方法确认是否有安装mysql-server,没有的话安装,有的话升级。
安装前最好查看以下具体的版本,然后选择合适的版本安装
# yum list mysql* //查询yum源中以mysql开头的所有包
# yum install mysql-server.x86_64 //这是我需要的版本,安装它
3,确认安装完成
# rpm -qa | grep mysql*
mysql-5.0.95-5.el5_9
mysql-server-5.0.95-5.el5_9
4,修改配置文件
# vi /etc/my.cnf
---------------------------my.cnf中-----------------------------------------
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
default-character-set=utf8 // 设置默认字符utf8
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
default-character-set=utf8 // 设置默认字符utf8
--------------------------------------------------------------------------------
保存退出。
5,修改mysql服务为系统自动启动,同时启动Mysql服务。
# chkconfig mysqld on // mysql服务为系统自动启动
确认以下设置成功
# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off // 2~5为on,OK。
# service mysqld start // 启动Mysql服务
然后用ps命令查看系统进程中是否有mysql。
确实有,OK。
6,接下来,要配置以下Mysql的用户,密码等信息。
# mysql -u root // 用root用户登录mysql
mysql> select user,host,password from mysql.user ; //查看用户密码
+------+-----------------------+----------+
| user | host | password |
+------+-----------------------+----------+
| root | localhost | |
| root | localhost.localdomain | |
| root | 127.0.0.1 | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+----------+
5 rows in set (0.00 sec)
从上可以看出,root用户的密码是空的,安全起见,都设下密码吧
mysql> set password for root@localhost=password('密码');
mysql> set password for root@localhost.localdomain=password('密码');
重新查询,发现已经设置好了。
mysql> select user,host,password from mysql.user ;
+------+-----------------------+------------------+
| user | host | password |
+------+-----------------------+------------------+
| root | localhost | 7261bbb77f35c935 |
| root | localhost.localdomain | 7261bbb77f35c935 |
| root | 127.0.0.1 | |
| | localhost | |
| | localhost.localdomain | |
+------+-----------------------+------------------+
5 rows in set (0.00 sec)
后面登录时:
# mysql -u root -p localhost(数据库名称)
Enter password:
7,上面的用户查询画面有用户名为空的项目,需要删除。
mysql> delete from mysql.user where user='';
Query OK, 2 rows affected (0.00 sec)
再查询下看看,里面就没有用户名为空的项了。
这样Mysql的安装基本上就完成了。
页:
[1]