mysql 5.5.32版本的数据库,在my.cnf中[client]添加default-character-set,不管用啊

mysql 5.5.32版本的数据库,在my.cnf中[client]添加default-character-set,不管用啊,第1张

执行这条命令show variables like 'char%'看看编码。

如果你是想改server编码应该在配置文件加上:

character_set_server = utf8

在重启mysql

如果修改其他几种编码,如database,client等直接执行sql就行,当然在配置文件加也行,但是得使用character_set_client =utf8

1.安装之前,先创建mysql用户

[root@linuxprobe_nfs ~]# useradd mysql -s /sbin/nologin -M

[root@linuxprobe_nfs ~]# id mysql

uid=500(mysql) gid=500(mysql) groups=500(mysql)

2.软件包的下载及解压

[root@linuxprobe_nfs ~]# mkdir /home/chenfan/tools -p

[root@linuxprobe_nfs ~]# cd /home/chenfan/tools

在http://dev.mysql.com/downloads/mysql/官网上下载mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@linuxprobe_nfs tools]# ls

mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@linuxprobe_nfs tools]# tar zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@linuxprobe_nfs tools]# ls

mysql-5.5.32-linux2.6-x86_64 mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@linuxprobe_nfs local]# mv mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql-5.5.32

###免编译安装

[root@linuxprobe_nfs local]# cd /usr/local

[root@linuxprobe_nfs local]# ln -s mysql-5.5.32 mysql

###此处的软链接为了版本升级提供了便利

3.初始化数据库

[root@linuxprobe_nfs local]# mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql

###此处如果初始化发生错误,删除data目录下的内容,rm -fr mysql/data/*,重新初始化。

4.生成MySQL配置文件

[root@linuxprobe_nfs local]# cd mysql

[root@linuxprobe_nfs mysql]# cp support-files/my-small.cnf /etc/my.cnf

5.授权管理文件

[root@linuxprobe_nfs ~]# chown -R mysql:mysql /usr/local/mysql/

[root@linuxprobe_nfs ~]# ls -ld /usr/local/mysql/

drwxr-xr-x. 13 mysql mysql 4096 Jun 24 17:21 /usr/local/mys

shell>groupadd mysql

shell>useradd -r -g mysql mysql

shell>cd /usr/local

shell>tar zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz

shell>mv mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql3309

shell>cd /usr/local/mysql3309

shell>chown -R mysql .

shell>chgrp -R mysql .

2

shell>cat my3309.cnf

#/usr/local/mysql3309下新建my3309.cnf配置文件,内容复制my3308.cnf

shell>mkdir /usr/local/mysql3309/logs

shell>mkdir /usr/local/mysql3309/bin-log

shell>chown -R mysql.mysql .

shell>scripts/mysql_install_db --user=mysql --defaults-file=/usr/local/mysql3309/my3309.cnf

-----------------------my3309.cnf内容--------------------------------------

[client]

#password = your_password

port = 3307

socket = /tmp/mysql3307.sock

[mysql]

socket = /tmp/mysql3307.sock

# The MySQL server

[mysqld]

port = 3309

socket = /tmp/mysql3307.sock

basedir =/usr/local/mysql3307

datadir =/usr/local/mysql3307/data

skip-external-locking

skip-host-cache

skip-name-resolve

max_connection =1000

key_buffer_size = 600M

max_allowed_packet = 10M

table_open_cache = 1024

sort_buffer_size = 6M

read_buffer_size = 6M

read_rnd_buffer_size = 8M

myisam_sort_buffer_size = 64M

thread_cache_size = 64

query_cache_size = 32M

# Try number of CPU's*2 for thread_concurrency

thread_concurrency = 8

log-error=/usr/local/mysql3307/logs/mysqld3307.log

server-id = 1

log_slave_updates = 1

auto_increment_increment=2

auto_increment_offset=2

read-only

log_bin =/usr/local/mysql3307/binlog/mysql-bin.log

#log-bin-index= mysql-bin.index

max_binlog_size =1G

max_relay_log_size =1G

expire_logs_days = 30 #超过30天的binlog删除

replicate-do-db =test #只复制某个库

replicate-do-db =fab

replicate-do-db =fat

replicate-do-db =thca

replicate-do-db =fab_innodb

replicate-ignore-db=mysql #不复制某个库

3

(启动mysql)

shell>bin/mysqld_safe --defaults-file=/usr/local/mysql3309/my3309.cnf --user=mysql >/dev/null 2>&1 &

(进入mysql)

shell>bin/mysql --defaults-file=/usr/local/mysql3309/my3309.cnf

4

无法启动或进入:

查看日志shell>tail -f /usr/local/mysql3309/logs/mysql3309.log

END

注意事项

解压缩版的mysql可直接运行,执行时需指定my.cnf文件

注意添加--defaults-file=/usr/local/my3309.cnf命令

由于在my.cnf文件中指定了mysql.sock的位置,为了避免多个mysql同时读取/tmp/mysql.sock文件,在启动时指定读取的sock文件位置: --socket=/tmp/mysql3307.sock


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7452230.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-05
下一篇 2023-04-05

发表评论

登录后才能评论

评论列表(0条)

保存