首页 » 操作系统 » Linux » CentOS下安装配置Mysql5.1

CentOS下安装配置Mysql5.1

 

1、利用CentOS下自带yum来安装mysql5.1

[root@localhost /]# yum install mysql-server

2、启动服务:

[root@localhost /]# service mysqld start     #启动mysql服务

[root@localhost /]# chkconfig mysqld on    #系统开机自动启动mysql服务

3、初始化mysql密码:

[root@localhost /]# /usr/bin/mysqladmin -u root password 123456

4、管理和创建Mysql数据库:

[root@localhost /]# mysql -u root -p

Enter password:    #输入刚才初始化的Mysql密码

创建数据库:

mysql> create database hmj;

远程登陆管理数据库授权:

mysql> grant all on *.* to 'root'@'172.16.100.110' IDENTIFIED BY '123456'with grant option;

5、备份数据库:

[root@localhost /]# mysqldump -uroot -p hmj >mysql2.sql     #把数据库hmj备份输出为.sql格式

6、Mysql字符编码修改:

解决mysql中文乱码问题

1)、复制my-large.cnf到/etc/my.cnf
[root@localhost mysql]# pwd
/usr/share/mysql
[root@localhost mysql]# cp my-large.cnf /etc/my.cnf      #注意权限

2)、 找到客户端配置[client] 在下面添加
### 默认字符集为utf8
default-character-set=utf8
在找到[mysqld] 添加
### 默认字符集为utf8
default-character-set=utf8

3)、修改好后,重新启动mysql服务即可,查询一下show variables like 'character%'; 可以看到编码都已经变为utf-8了:

mysql> show variables like '%char%';
 +-------------------------------+-----------------------------+
 | Variable_name                 | Value                       |
 +-------------------------------+-----------------------------+
 | character_set_client          | utf8                        |
 | character_set_connection      | utf8                        |
 | character_set_database        | utf8                        |
 | character_set_filesystem      | binary                      |
 | character_set_results         | utf8                        |
 | character_set_server          | utf8                        |
 | character_set_system          | utf8                        |
 | character_sets_dir            | /usr/share/mysql/charsets/  | 
 +-------------------------------+-----------------------------+
 8 rows in set (0.00 sec)

原文链接:CentOS下安装配置Mysql5.1,转载请注明来源!

1