1、问题:登陆mysql查看表信息时中文出现乱码
为了防止中文出现乱码修改下面脚本:
#vi /home/coremail/bin/mysql_cm
#!/bin/sh
/home/coremail/mysql/bin/mysql -ucoremail -p3376211849 -h127.0.0.1 -P3308 cmxt --default-character-set=gbk
mysql> show variables like '%char%';
+--------------------------+--------------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | latin1 |
| character_set_results | gbk |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /home/coremail/mysql/share/mysql/charsets/ |
+--------------------------+--------------------------------------------+
给root用户设置密码
#mysqladmin -u root password '123456'
修改root用户密码
#mysqladmin -uroot -p123456 password ' secret '
忘记root用户名密码,解决方法:
#service mysql stop
# /usr/bin/mysqld_safe --skip-grant-tables &
#mysql
mysql> use mysql
mysql> UPDATE user SET password=password('123456') WHERE user='root';
查看数据编码方式:
status;
导入数据
source a.sql;
2.问题:修改mysql日志路径
vim /etc/my.cnf
log-bin = mysql-bin
修改为:
log-bin = /$PATH/mysql-bin
修改完毕后,保存退出。
修改mysql-bin.index文件,修改其中现有日志的路径。
默认为:./mysql-bin.....
修改为:/$PATH/mysql-bin....
全部替换后即可重启mysql服务,否则会重启出错。
3、问题:Error: 'Lost connection to MySQL server at 'reading initial communication packet', system error: 113' errno: 2013 retry-time: 30 retries: 86400
解决办法:在 my.cnf 里面的 [mysqld] 段增加一个启动参数
skip-name-resolve
保存重启即可。 skip-name-resolve 选项可以禁用dns解析。
4、问题:Error reading packet from server: Access denied; you need the REPLICATION SLAVE privilege for this operation ( server_errno=1227)
解决办法:主服务器给的复制权限不够,重新赋予权限。
grant replication slave on *.* to 'replication'@'ip地址' identified by '密码';
flush privileges;
远程重新测试即正常。