Mysql在Linux下安装和使用过程中出现的问题及解决方案_MySQL
一、 CentOS 7.**版本无法安装Mysql;
原因分析:
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。因此CentOS 7上为了防范这个潜在问题的出现,已经将MariaDB作为首要数据库进行了打包安装。这样的话,如果我们再安装Mysql的话,就会提示冲突或者已存在一个相似的版本了。
解决方案:
卸载MariaDB;
强制卸载关于MariaDb的所有软件及关联库信息;
1、 查看当前安装的mariadb包:
[root@bogon]# rpm -qa | grep mariadb
2、 将它们统统强制性卸载掉:
[root@bogon]# rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64
[root@bogon]# rpm -e --nodeps mariadb-5.5.35-3.el7.x86_64
[root@bogon]# rpm -e --nodeps mariadb-server-5.5.35-3.el7.x86_64
安装Mysql
方法1、双击下面三个包进行自动安装:
MySQL-client-advanced-5.6.22-1.el7.x86_64.rpm
MySQL-devel-advanced-5.6.22-1.el7.x86_64.rpm
MySQL-server-advanced-5.6.22-1.el7.x86_64.rpm
(提示:其实第二个包devel我也不知道是干什么的,也不知道是不是必须的(上网搜了一下应该不是必须的),没有测试是否必须就已经点来装上了,也不想花时间去测试是否必须了,有测试过的朋友麻烦留言告知。)
方法2、使用rpm命令进行安装(针对.rpm包)
rpm -iUvh MySQL-client-advanced-5.6.22-1.el7.x86_64.rpm
rpm -iUvh MySQL-devel-advanced-5.6.22-1.el7.x86_64.rpm
rpm -iUvh MySQL-server-advanced-5.6.22-1.el7.x86_64.rpm
二、 Mysql安装完毕进入不了
安装完毕Mysql后,使用命令service mysql start时报如下错误:
ERROR!The server quit without updating PID file
解决方案:
主要是因为:selinux惹的祸,如果是centos系统,默认会开启selinux。解决方法是关闭它,打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器。
三、 无法直接进入Mysql
使用命令进入mysql时,不起作用,报如下错误
[root@bogon ]# mysql -u root –p
ERROR 1045 (28000):Access denied for user'root'@'localhost' (using password: YES)
解决方法
1、 停止mysql服务;
[root@bogon]# service mysql stop
2、 使用mysql-safe命令绕过密码安全登录;
[root@bogon]# mysqld_safe --user=mysql --skip-grant-tables--skip-networking &
3、 输入登录用户名和密码
[root@bogon]# mysql -u root –p
4、 进去之后重置密码
mysql>SET PASSWORD = PASSWORD('passok')
注:这也是防止另外一个错误ERROR 1820(HY000):You must SET PASSWORD before executing this statement
四、 远程管理终端无法进入Mysql
ERROR 1130:Host '192.168.1.3' is not allowed to connect to this MySQL server
解决方法:
方法一、改表法:localhost改成%
进入mysql的BIN目录
[root@bogon ]# mysql -u root –p
mysql>usemysql;
mysql>select'host' from user where user='root';
mysql>updateuser set host =’%'where user =’root’;
具体语句分析
1、在本机登入mysql后,更改“mysql”数据库里的“user”表里的“host”项,从”localhost”改为'%'。具体分析
2、查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称)
3、修改host值(以通配符%的内容增加主机/IP地址,当然也可以直接增加某个特定IP地址
注意:如果执行update语句时出现ERROR1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 错误,需要
selecthost from user where user = 'root';
查看一下host是否已经有了%这个值,如果有了直接执行下面的flush privileges;即可)
代码如下
mysql>selecthost,user from user where user='root';
mysql>flushprivileges;
方法2: 授权法例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话
使用命令:GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.3' IDENTIFIEDBY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANTALL PRIVILEGES ON *.* TO 'root'@'192.168.3.2' IDENTIFIEDBY ‘123456’ WITH GRANT OPTION;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Win11 is the latest operating system launched by Microsoft. Compared with previous versions, Win11 has greatly improved the interface design and user experience. However, some users reported that they encountered the problem of being unable to install the Chinese language pack after installing Win11, which caused trouble for them to use Chinese in the system. This article will provide some solutions to the problem that Win11 cannot install the Chinese language pack to help users use Chinese smoothly. First, we need to understand why the Chinese language pack cannot be installed. Generally speaking, Win11

Reasons and solutions for scipy library installation failure, specific code examples are required When performing scientific calculations in Python, scipy is a very commonly used library, which provides many functions for numerical calculations, optimization, statistics, and signal processing. However, when installing the scipy library, sometimes you encounter some problems, causing the installation to fail. This article will explore the main reasons why scipy library installation fails and provide corresponding solutions. Installation of dependent packages failed. The scipy library depends on some other Python libraries, such as nu.

Common problems and solutions for OracleNVL function Oracle database is a widely used relational database system, and it is often necessary to deal with null values during data processing. In order to deal with the problems caused by null values, Oracle provides the NVL function to handle null values. This article will introduce common problems and solutions of NVL functions, and provide specific code examples. Question 1: Improper usage of NVL function. The basic syntax of NVL function is: NVL(expr1,default_value).

Title: An effective solution to solve the problem of garbled characters caused by Oracle character set modification. In Oracle database, when the character set is modified, the problem of garbled characters often occurs due to the presence of incompatible characters in the data. In order to solve this problem, we need to adopt some effective solutions. This article will introduce some specific solutions and code examples to solve the problem of garbled characters caused by Oracle character set modification. 1. Export data and reset the character set. First, we can export the data in the database by using the expdp command.

Common challenges faced by machine learning algorithms in C++ include memory management, multi-threading, performance optimization, and maintainability. Solutions include using smart pointers, modern threading libraries, SIMD instructions and third-party libraries, as well as following coding style guidelines and using automation tools. Practical cases show how to use the Eigen library to implement linear regression algorithms, effectively manage memory and use high-performance matrix operations.

PyCharm is a powerful Python integrated development environment that is widely loved by developers. However, sometimes we may encounter key invalidation problems when using PyCharm, resulting in the inability to use the software normally. This article will reveal the solution to PyCharm key failure and provide specific code examples to help readers quickly solve this problem. Before we start solving the problem, we first need to understand why the key is invalid. PyCharm key failure is usually due to network problems or the software itself

Common reasons and solutions for Chinese garbled characters in MySQL installation MySQL is a commonly used relational database management system, but you may encounter the problem of Chinese garbled characters during use, which brings trouble to developers and system administrators. The problem of Chinese garbled characters is mainly caused by incorrect character set settings, inconsistent character sets between the database server and the client, etc. This article will introduce in detail the common causes and solutions of Chinese garbled characters in MySQL installation to help everyone better solve this problem. 1. Common reasons: character set setting

Common causes and solutions for PHP Chinese garbled characters. With the development of the Internet, Chinese websites play an increasingly important role in our lives. However, in PHP development, the problem of Chinese garbled characters is still a common problem that troubles developers. This article will introduce the common causes of Chinese garbled characters in PHP and provide solutions. It also attaches specific code examples for readers' reference. 1. Common reasons: Inconsistent character encoding: Inconsistencies in PHP file encoding, database encoding, HTML page encoding, etc. may lead to Chinese garbled characters. database
