当前位置:网站首页>Common problems in installing mysql in linux environment and using it
Common problems in installing mysql in linux environment and using it
2022-08-08 23:37:00 【programmer lm】
Based on the environment is centos 6.8 mysql 5.6.24版本
1.执行命令 service msyql status查看mysqlThe running times wrong:MySQL is not running, but lock file
解决:Removing the lock file,并把该lockSet the file location;
rm /var/lock/subsys/mysql lock file 在 /etc/rc.d/init.d/mysql Set the changelockdir
vi /etc/rc.d/init.d/mysql
2.重启mysql服务的时候 报错:
Starting MySQL........The server quit without updating PID [失败]/usr/local/mysql/data/mysql/hadoop102.pid).
解决:Directly to find the corresponding file viewpid文件,这个hadoop102.pidIs actually an error log file,也有可能叫hadoop102.err(hadoop102这里是你linux主机的名称)
cat /usr/local/mysql/data/mysql/hadoop102.pidWhen I met the specific error message shown in figure:

原因:Actually this is to set the default encoding format I was wrong;
打开 vi /usr/my.cnf 文件(Some of the default configuration file in/etc/my.cnf)
注释掉 default-character-set=utf8Or change the position,写在client下就行
service mysql start Restart it so that the
In view of the set encoding format added:
[client]下添加:default-character-set=utf8
[mysqld]下添加:character_set_server=utf8
3.启动mysql 服务的时候 报错 can't open the mysql plugin table
解决:Is starting to findmysql 的数据文件. mysql The data files the default location for /var/lib/mysql
Check your configuration file vi /usr/my.cnf 文件 datadir的配置
My own configuration as 如图

因此针对这个问题,可以有两种解决方式:
1)将/var/lib/mysql All data files to/usr/local/mysql/data 下
mv /var/lib/mysql /usr/local/mysql/data2)修改my.cnf文件中,数据的存放路径,同时需要修改Mysql启动文件 /etc/rc.d/init.d/mysql 中datadir
vi my.cnf 添加如下一行

修改MySQL启动脚本/etc/rc.d/init.d/mysql
vi /etc/rc.d/init.d/mysql添加 datadir=/usr/local/mysql/data/mysql ,如图

4. 在创建表时 报错[Err] 1071 - Specified key was too long; max key length is 767 byte
原因:MySQL的varchar主键只支持不超过768个字节 或者 768/2=384个双字节 或者 768/3=256个三字节的字段 ,而 GBK是双字节的,UTF-8是三字节的.In the script has three indexes based on the coding forGBK,varchar(500)的字段上,So lead to exceed limit the length of the.
解决:修改默认编码为utf8
[client]下添加:default-character-set=utf8
[mysqld]下添加:character_set_server=utf8

但是需要注意的是,Before change the coding format to create the database will keep creating coding format,So after change the database encoding format,Need to establish a database!
5.在使用socket连接方式 报错:mysql Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
1)可以修改smysql.sock 存放目录(my.cnfSome machines also in/etc/my.cnf下),Want to find the perform whereis my.cnf
vi /usr/my.cnf 在【mysqld】下添加 socket =/usr/local/mysql/data/mysql/mysql.sock
然后重启mysql 服务
service msyql restart2)连接时指定 socket目录
mysql -uroot -p123456 --socket='/usr/local/mysql/data/mysql/mysql.sock'3)通过mysql.sockSet up soft connection in implementsocket连接
ln -s /usr/local/mysql/data/mysql/mysql.sock /var/lib/mysql/mysql.sockWill I set 的socket文件位置,在/var/lib/mysqlPlaced under a,以供读取
结果如图:

版权声明:本文为博主原创文章,转载请注明本页地址.https://blog.csdn.net/l1994m/article/details/88198640
边栏推荐
猜你喜欢
随机推荐
Introduction to basic grammar and the foundation of freemarker
关于vm虚拟机虚拟网络已禁用
(2022牛客多校四)A-Task Computing (排序+动态规划)
机器学习建模高级用法!构建企业级AI建模流水线
[Bug solution] ValueError: Object arrays cannot be loaded when allow_pickle=False
Use Mongoose populate to implement multi-table associative storage and query, with complete code included
(2022杭电多校三)1002-Boss Rush(状压DP+二分)
stm32 uses spi1 to read data from dma in slave mode
stm32 利用 串口接收空闲中断 + dma 实现不定长度dma 接收
2022杭电多校六 1007-Shinobu loves trip(同余方程)
2022杭电多校六 1009-Map (巴那赫不动点)
(nowcoder22529C)dinner(容斥原理+排列组合)
Hand-written prometheus exporter-01-Gauge (dashboard)
moved异常,ask重定向
STM8L LCD digital tube driver, thermometer LCD display
(2022杭电多校四)1011-Link is as bear(思维+线性基)
PMP考点有哪些啊?
makefile automatically compiles C files in directories and subdirectories
Modal dialog is used to implement the sign-in
51nod 2882最短路 (树链剖分)
![[Pytorch] Study Notes (1)](/img/3d/5e66564bec5c787c87738bcf58c37b.png)

![[GYCTF2020]Ezsqli-1|SQL注入](/img/02/dd53f409d278c85b0d48108c4c0148.png)






