>  기사  >  데이터 베이스  >  MySQL编码Linux平台

MySQL编码Linux平台

WBOY
WBOY원래의
2016-06-07 16:51:381112검색

Linux下安装MySQL5.0.37需要以下面三个包:MySQL-client-community-5.0.37-0.rhel3.i386.rpmMySQL-server-community-5.0.37-0.rhe

Linux下安装MySQL5.0.37需要以下面三个包:
MySQL-client-community-5.0.37-0.rhel3.i386.rpm
MySQL-server-community-5.0.37-0.rhel3.i386.rpm
perl-DBI-1.53-2.fc7.i386.rpm
(以下步骤需要root权限)
1.验证是否已经安装过MySQL
rpm -qa|grep MySQL
如果发现有安装过,并需要卸载,使用下面命令
rpm -e MySQL-client-community MySQL-server-community
2.安装
执行:rpm -ivh MySQL-client-community-5.0.37-0.rhel3.i386.rpm MySQL-server-community-5.0.37-0.rhel3.i386.rpm
如果控制台提示:
error: Failed dependencies:
perl(DBI) is needed by MySQL-client-community-5.0.37-0.rhel3.i386
perl(DBI) is needed by MySQL-server-community-5.0.37-0.rhel3.i386
代表当前操作系统缺少DBI模块,请先安装DBI模块.
rpm -ivh perl-DBI-1.53-2.fc7.i386.rpm
提示下面文字代表正确安装:
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]
重新执行MySQL的安装命令
提示下面文字代表正确安装:
Preparing... ########################################### [100%]
1:MySQL-server-community ########################################### [ 50%]
2:MySQL-client-community ########################################### [100%]
3.初始化安装
/usr/bin/mysql_install_db
4.启动mysql
/etc/init.d/mysql start
(停止有两种方法:[mysqladmin -uroot -p shutdown] [/etc/init.d/mysql stop])
5.验证安装成功
netstat -nat|grep 3306
如果能看到下面一行说明正常安装:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
6.修改mysql的root用户密码
mysqladmin -u root password '123456'
7.登陆mysql客户端
mysql -uroot -p
输入:123456
8.建立数据库
mysql> create database gbkdb character set gbk;
Query OK, 1 row affected (0.01 sec)
9.为数据库gbkdb建立用户(用户:user 密码:123)
mysql> grant select,insert,update,delete,create on gbkdb.* to user@"%" identified by "123";
Query OK, 0 rows affected (0.01 sec)10.修改配置
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
vi /etc/my.cnf
在[client]下面增加一行:
[client]
default-character-set = gbk
在[mysqld]下面增加三行:
[mysqld]
default-character-set = gbk
default-collation = gbk_chinese_ci
init_connect = 'SET NAMES gbk'
在[mysql]下面增加一行:
[mysql]
default-character-set = gbk
11.重启MySQL
/etc/init.d/mysql restart
12.重登陆mysql控制台确认配置变化
mysql -uroot -p
输入:123456
mysql> show variables like 'character_set_%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
13.在远程使用控制台登陆,确认用户可以使用
mysql -h10.10.1.156 -uuser -p
输入:123
mysql> use gbkdb;
Database changed

linux

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.