0
点赞
收藏
分享

微信扫一扫

mysql安装常见错误及解决

女侠展昭 2021-09-25 阅读 102

问题1:

Starting MySQL...Manager of pid-file quit without updating[failue]

  • 解决办法:
    修改启动脚本文件:/etc/init.d/mysqld
    conf=/usr/local/mysql/etc/my.cnf

问题2:

[root@localhost scripts]# ./mysql_install_db --user=mysql --datadir=/database/mydata
FATAL ERROR: please install the following Perl modules before executing ./mysql_install_db:
Data::Dumper

  • 解决办法:
  1. [root@localhost scripts]# rpm -ivh /mnt/Packages/perl-Data-Dumper-2.145-3.el7.x86_64.rpm
    warning: /mnt/Packages/perl-Data-Dumper-2.145-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
    Preparing... ################################# [100%]
    Updating / installing...
    1:perl-Data-Dumper-2.145-3.el7 ################################# [100%]
  2. 方案2
    解决方法 :安装autoconf库
    命令:yum-y install autoconf

linux 安装mysql 报错 :
Installing MySQL system tables.../usr/local/mysql//bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

安装 yum -y install libaio-devel 之后问题还是依旧 CentOS 7.3 64位
少东西,centos用yum装yum -y install numactl

问题3:

linux启动mysql报Fatal error:Can't change to run as user 'mysql' Please check that the user exists

  • 解决办法:
    1、创建mysql用户
    useradd mysql
    2、mysql目录改为mysql读写权限
    chown -R mysql:mysql /var/lib/mysql
    chown -R mysql:mysql /usr/local/mysql

问题4

[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/database/mydata
Installing MySQL system tables...2015-10-30 14:18:43 5981 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-30 14:18:43 5981 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-30 14:18:43 5981 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-30 14:18:43 5981 [Note] InnoDB: Memory barrier is not used
2015-10-30 14:18:43 5981 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-10-30 14:18:43 5981 [Note] InnoDB: Using CPU crc32 instructions
2015-10-30 14:18:43 5981 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-30 14:18:43 5981 [Note] InnoDB: Completed initialization of buffer pool
2015-10-30 14:18:43 5981 [Note] InnoDB: Restoring page 0 of tablespace 0
2015-10-30 14:18:43 5981 [Warning] InnoDB: Doublewrite does not have page_no=0 of space: 0
2015-10-30 14:18:43 5981 [ERROR] InnoDB: space header page consists of zero bytes in data file ./ibdata1
2015-10-30 14:18:43 5981 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2015-10-30 14:18:43 5981 [ERROR] Plugin 'InnoDB' init function returned error.
2015-10-30 14:18:43 5981 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-10-30 14:18:43 5981 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-10-30 14:18:43 5981 [ERROR] Aborting

2015-10-30 14:18:43 5981 [Note] Binlog end
2015-10-30 14:18:43 5981 [Note] ./bin/mysqld: Shutdown complete

  • 解决办法:

1.删除数据库目录下的文件ib_logfile0和ib_logfile1,我在安装时定义的数据库目录是/database/mydata

rm -rf /database/mydata/l

2.再次执行脚本

[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/database/mydata

安装mysql 5.7过程中出现如下问题:

[root@db mysql-5.7]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.7/ --datadir=/u01/data/mysql/
2018-12-25 18:46:40 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2018-12-25 18:46:40 [ERROR] Child process: /usr/local/mysql-5.7/bin/mysqldterminated prematurely with errno= 32
2018-12-25 18:46:40 [ERROR] Failed to execute /usr/local/mysql-5.7/bin/mysqld --bootstrap --datadir=/u01/data/mysql --lc-messages-dir=/usr/local/mysql-5.7/share --lc-messages=en_US --basedir=/usr/local/mysql-5.7
-- server log begin --
/usr/local/mysql-5.7/bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory

-- server log end --

解决方法:

下载文件numactl-2.0.9-2.el6.x86_64.rpm,然后安装即可。

文件下载地址:http://mirror.centos.org/centos/6/os/x86_64/Packages/numactl-2.0.9-2.el6.x86_64.rpm

[root@db soft]# chmod +x *.rpm
[root@db soft]# rpm -ivh numactl-2.0.9-2.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:numactl ########################################### [100%]

5、常见问题汇总:

  1. [root@iZ2zeg11g0cdei5171kqskZ mysql]# ./scripts/mysql_install_db --user=mysqlInstalling MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
  • 解决:

yum -y install libaio-devel

  1. [root@iZ2zeg11g0cdei5171kqskZ mysql]# service mysqld startStarting MySQL.touch: cannot touch '/var/log/mariadb/mariadb.log': No such file or directorychmod: cannot access '/var/log/mariadb/mariadb.log': No such file or directorytouch: cannot touch '/var/log/mariadb/mariadb.log': No such file or directorychown: cannot access '/var/log/mariadb/mariadb.log': No such file or directory/usr/local/mysql//bin/mysqld_safe: line 129: /var/log/mariadb/mariadb.log: No such file or directory/usr/local/mysql//bin/mysqld_safe: line 166: /var/log/mariadb/mariadb.log: No such file or directorytouch: cannot touch '/var/log/mariadb/mariadb.log': No such file or directorychown: cannot access '/var/log/mariadb/mariadb.log': No such file or directorychmod: cannot access '/var/log/mariadb/mariadb.log': No such file or directory/usr/local/mysql//bin/mysqld_safe: line 129: /var/log/mariadb/mariadb.log: No such file or directoryThe server quit without updating PID file (/var/lib/mysql/i[FAILED]0cdei5171kqskZ.pid).
  • 解决:(我们确实是没有/var/log/mariadb/mariadb.log 这个目录,这个是因为你没有指定他的配置文件的话,他会默认找到/etc/my.cnf 这个配置文件,因为我们修改了mysql的数据存储目录)、

rm -f /etc/my.cnf

  1. [root@iZ2zeg11g0cdei5171kqskZ mysql]# mysql -uroot -p-bash: mysql: command not found
  • 解决:(这个是因为/usr/local/bin目录下缺失mysql导致,只需要一下方法建立软链接,即可以解决)
    ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
  1. sqlyog连接时,报1130错误,是由于没有给远程连接的用户权限问题
  • 解决1:更改 ‘mysql’数据库‘user’表‘host’项,从‘localhost’改成‘%’。
    use mysql;
    select 'host' from user where user='root';
    update user set host = '%' where user ='root';
    flush privileges;

  • 解决2:直接授权
    GRANT ALL PRIVILEGES ON . TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;

  1. -bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
  • 解决:
    yum -y install perl perl-devel
  1. Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
  • 解决:
    yum -y install libaio-devel
  1. 环境变量配置位置:
    vi + /etc/profile

  2. 远程访问时要关闭防火墙或者打开mysql的端口,如果用的阿里云则要在服务器管理界面对端口进行设置,而不是在系统内部设置

9.问题描述:搭建完MySQL,用远程连接工具(Navicat)连接时报错:
2013-Lost connection to MySQL server at 'waiting for intial communication packet',system error:0

  • 解决:
    原因分析:
    MySQL开启了DNS的反向解析功能,这样MySQL对连接的客户端会进行DNS主机名查找;

解决方式:

找到mysql安装配置文件:my.cnf;路径因环境而异。如果你的是Liunx的环境,可以去目录:/etc/my.cnf中查找

编辑文件:my.cnf,找到【mysqld】模块

在其下增加一行:skip-name-resolve 如下图所示:

保存退出,并重启mysql服务:service mysql restart 即可,再重新连接看看!

10.问题:[mysql]ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
第一种方法:
原因:在我的配置文件my.cnf中有这样一条语句
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
指定了严格模式,为了安全,严格模式禁止通过insert 这种形式直接修改mysql库中的user表进行添加新用户
解决办法:

将配置文件中的STRICT_TRANS_TABLES删掉,即改为:
sql_mode=NO_ENGINE_SUBSTITUTION

然后重启mysql即可

第二种方法:

grant usage on *.* to ['username'@'hostname'](mailto:'%20rel=) identified by 'passwd' with grant option;  //添加用户

grant all privileges on *.* to ['username'@'hostname'](mailto:'%20rel=) identified by 'passwd'; //添加权限

flush privileges; //更新权限

11.问题: mysqldump导出数据库时 Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)


分析:这个文件是初始化后生成到配置文件指定到的目录下的,vim /etc/my.cnf报错信息提示的路劲跟配置的路劲发现不一样,先查看这个文件存不存在,发现它是存在的,但是还是报错。根据它的提示,是去找默认的路劲,/tmp下面的mysql.sock,但是我们指定的路径是在自己的安装目录下解决办法就是,设置软连接。


解决:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock (实际配置文件中的mysql.sock路径,软链接到/tmp/mysql.sock)

问题12: SELECT list is not in GROUP BY clause........ which is not functionally dependent on columns in GROUP BY clause;this is incompatible with sql_mode=only_full_group_by
分析:ONLY_FULL_GROUP_BY是MySQL提供的一个sql_mode,通过这个sql_mode来提供SQL语句GROUP BY合法性的检查,在MySQL的sql_mode是非ONLY_FULL_GROUP_BY语义时。一条select语句,MySQL允许target list中输出的表达式是除聚集函数或group by column以外的表达式,这个表达式的值可能在经过group by操作后变成undefined,而对于语义限制都比较严谨的多家数据库,如SQLServer、Oracle、PostgreSql都不支持select target list中出现语义不明确的列,这样的语句在这些数据库中是会被报错的,所以从MySQL 5.7版本开始修正了这个语义,就是我们所说的ONLY_FULL_GROUP_BY语义

查询全局sql_mode可得
select @@GLOBAL.sql_mode;


解决: 1 全局删除sql_mode中的ONLY_FULL_GROUP_BY选项

set @@GLOBAL.sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

2 修改mysql配置文件,在[mysqld]模块下添加如下代码

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

第一种方式会在重启mysql之后失效.请根据自己的需要选择解决方案

问题13:使用group_concat获取结果集字符串不全问题
分析:mysql的group_concat默认连接长度为1024字符,也就是说你需要连接后的连接超过1024字符,它只会显示这么长,其余部分都会被截取丢掉。

解决:
1.全局设置group_concat限制长度

       #查询group_concat函数限制长度
SELECT @@global.group_concat_max_len;
show variables like "group_concat_max_len";
#使用以下语句设置:
SET GLOBAL group_concat_max_len=102400;
SET SESSION group_concat_max_len=102400;

2.在MySQL配置文件中my.conf或my.ini中添加如下代码然后重启MySQL服务

  #[mysqld]
  group_concat_max_len=102400

问题14:win10下手动启动mysql服务,显示Windows无法启动mysql服务(位于本地计算机上)。 错误1053:服务没有及时响应启动或控制请求。

mysql 1053错误,无法启动的解决方法
windows2003服务器中,服务器重启后Mysql却没有启动,手动启动服务时提示[1053]错误。

1.在DOS命令行使用
第一步:
mysqld-nt remove mysqlservice
#的方式卸载此服务,它提示卸载成功,(是英文成功的意思)
第二步:mysqld-nt install mysqlservice
#重新注册服务,一切恢复正常。(也会英文显示成功)
第三步:打开 服务>>>>禁用MYSQL>>>>再启动MYSQL
2.
”我的电脑“ -> 右击 ->“服务” -> 找到 mysql服务 ->右键 “属性” -> 选择“登录”选项卡 输入帐户名或者浏览用户名选择其用户名,输入密码和确认密码,点“确定

3.删掉 ib_logfile0,ib_logfile1两个日志文件就行了。(本人通过这个方法解决问题)

#如果找不到data文件夹,可以查看**mysql**文件目录**my.ini**文件,可以找到类似于 **datadir**=”D:/beeagle/Program Files/MySQL/MySQL Server 5.0/Data/”的字段 该路径为mysql data目录 默认在:”C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\Data\” **注意:Application Data****文件夹是隐藏的!!!**可以修改上述配置,把Data文件夹放在你想放的地方。

举报

相关推荐

0 条评论