GVKun编程网logo

centos6.5 二进制安装mysql5.6 遇到的问题(二进制安装mysql5.7)

13

以上就是给各位分享centos6.5二进制安装mysql5.6遇到的问题,其中也会对二进制安装mysql5.7进行解释,同时本文还将给你拓展021_centos6.5二进制安装mysql.5.7.25

以上就是给各位分享centos6.5 二进制安装mysql5.6 遇到的问题,其中也会对二进制安装mysql5.7进行解释,同时本文还将给你拓展021_centos6.5二进制安装mysql.5.7.25、1.2二进制安装MySQL5.7、CenterOS7 安装Mysql8 及安装会遇到的问题、CentOS 6.3 安装Mysql 遇到的问题等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

centos6.5 二进制安装mysql5.6 遇到的问题(二进制安装mysql5.7)

centos6.5 二进制安装mysql5.6 遇到的问题(二进制安装mysql5.7)

wget "http://mirrors.sohu.com/MysqL/mysql-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz"


tar -xf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz -C /home/MysqL3308/

cd /home/MysqL3308/

mv mysql-5.6.35-linux-glibc2.5-x86_64/ MysqL3308



初始化:在当前目录下生成默认的my.cnf文件

./scripts/MysqL_install_db --user=MysqL3308 --basedir=/home/MysqL3308/ --datadir=/home/MysqL3308/data/


/home/MysqL3308/bin/MysqLd_safe --defaults-file=/home/MysqL3308/conf/my.cnf & #用自己的配置文件

报错:MysqL_safe 默认的路径是/usr/local/MysqL,所以要换一下路径


vim /home/MysqL3308/bin/MysqLd_safe

MY_PWD='/home/MysqL3308'


/home/MysqL3308/bin/MysqLd_safe --defaults-file=/home/MysqL3308/conf/my.cnf &

启动MysqL成功


因为我当时忘了搞啥了,反正就是没找到.MysqL_secret文件,所以没有找到初始密码,所以悲催的只能自己设置:


设置初始密码:

1、/home/MysqL3308//bin/MysqLadmin -u root password 'he123321ha' -S /home/MysqL3308/data/MysqL.sock

报错:root 不允许localhost登录


2、/home/MysqL3308/bin/MysqL_secure_installation

报错找不到sock:

解决:

vim /home/MysqL3308/bin/MysqL_secure_installation

sub make_config {

my $password = shift;


my $esc_pass = basic_single_escape($rootpass);

write_file($config,

"# MysqL_secure_installation config file",

"[MysqL]",

"user=root",

"password='$esc_pass'",

"socket=/home/MysqL3308/data/MysqL.sock",

"connect-expired-password");

}


添加一行"socket=/home/MysqL3308/data/MysqL.sock",这样就解决了找不到sock的问题,可是还会报错root 不允许localhost登录,简直气死个人。




####上面这2个设置初始密码都因为不允许root localhost登录,都失败了,白折腾,所以还是要用跳过认证的方式#####


解决:

关闭MysqL的2种方式:

1、/home/MysqL3308//bin/MysqLadmin -S /home/MysqL3308/data/MysqL.sock shutdown -uroot -p

会报错,因为此时没有密码。


2、kill -9 MysqL的进程号



加--skip-grant-tables 跳过密码认证:

/home/MysqL3308/bin/MysqLd_safe --defaults-file=/home/MysqL3308/conf/my.cnf --skip-grant-tables &


MysqL -uroot -p -S /home/MysqL3308/data/MysqL.sock

回车直接登录进去


use MysqL;


update user set password=password('123456') where user='root' and host='localhost';


flush privileges;

exit


/home/MysqL3308//bin/MysqLadmin -S /home/MysqL3308/data/MysqL.sock shutdown -uroot -p 此时该命令也不报错了,可以成功关闭MysqL了,因为密码生效了。



MysqL -uroot -p -S /home/MysqL3308/data/MysqL.sock

输入刚才设置的密码:成功登录

021_centos6.5二进制安装mysql.5.7.25

021_centos6.5二进制安装mysql.5.7.25

下载二进制包

打开官网(https://www.MysqL.com)->点击顶部第二个菜单(DOWNLOAD)->拖到页面底部,找到(MysqL Communit y Edition (GPL) Community (GPL) Downloads ?)并点击->找到第一条(MysqL Community Server (GPL)),点击下方(DOWNLOAD)链接->找到(MysqL Community Server 5.7 ?)链接并点击->找到(Select Version:)选择最高版本;找到(Select Operating System:)选择(Linux - Generic);找到(Select OS Version:)选择(Linux - Generic(glibc2.12)(x86,64-bit))->找到(MysqL-5.7.25-linux-glibc2.12-x86_64.tar.gz),点击(DOWNLOAD)->找到(No thanks,just start my download.)并点击进行下载

准备工作(ROOT账号操作)

卸载MysqL

#查询已安装MysqL
rpm -qa|grep MysqL
#卸载上一步查询结果,...代表上一步查询结果项
rpm -e --nodeps  ...#多个用空格隔开
#查看是否存在MysqL进程,如果存在依次kill -9停止进程
ps -ef|grep MysqL|grep -v grep

删除用户

userdel -r MysqL

创建用户、组

useradd -r MysqL

安装linux开发工具包

yum -y groupinstall ‘Development Tools‘

创建安装目录及日志文件

mkdir -p /MysqL;
touch /MysqL/MysqL-error.log;

上传安装包并解压

/MysqL/MysqL-5.7.25-linux-glibc2.12-x86_64.tar.gz
tar -xzvf /MysqL/MysqL-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /MysqL/;
mv /MysqL/MysqL-5.7.25-linux-glibc2.12-x86_64/* /MysqL/;
rm -rf /MysqL/MysqL-5.7.25-linux-glibc2.12-x86_64;

修改启动文件配置

#编辑文件
vi /MysqL/support-files/MysqL.server
#找到basedir,datadir,并配置如下:
basedir=/MysqL
datadir=/MysqL/data

修改/etc/my.cnf

su - root
 vi /etc/my.cnf
 #清空后添加如下配置
[client] 
port=3306
socket=/MysqL/MysqL.sock
default-character-set=utf8
[MysqLd]
port=3306
character-set-server=utf8
default_storage_engine = innodb
log_timestamps = SYstem
socket = /MysqL/MysqL.sock
basedir= /MysqL
datadir = /MysqL/data
pid-file = /MysqL/MysqL.pid
max_connections = 1000
max_connect_errors = 1000
table_open_cache = 1024
max_allowed_packet = 128M
open_files_limit = 65535
explicit_defaults_for_timestamp=true
expire_logs_days=30
#####====================================[innodb]==============================
innodb_buffer_pool_size = 1024M
innodb_file_per_table = 1
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_purge_threads = 2
innodb_flush_log_at_trx_commit = 1
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_max_dirty_pages_pct = 80
innodb_lock_wait_timeout = 30
innodb_data_file_path=ibdata1:1024M:autoextend
#####====================================[log]==============================
log_error = /MysqL/MysqL-error.log
slow_query_log = 1
long_query_time = 1 
slow_query_log_file = /MysqL/MysqL-slow.log

添加MySQL命令链接

ln -s /MysqL/bin/MysqL /usr/local/bin/MysqL

配置MysqL启动服务

cp /MysqL/support-files/MysqL.server /etc/init.d/MysqLd;
chmod 755 /etc/init.d/MysqLd;
chkconfig --add MysqLd;
chkconfig MysqLd on;

开启3306端口

打开3306端口,允许远程访问
centos7
firewall-cmd --zone=public --add-port=3306/tcp --permanent;
firewall-cmd --reload;
centos6
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT;
/etc/rc.d/init.d/iptables save;
service iptables restart;

配置开机启动

vi /etc/rc.local
#添加
service MysqLd start

目录授权

chown MysqL:MysqL /MysqL -R

安装(MysqL账号操作)

切换到MysqL

su - MysqL #一定要加-

初始化

/MysqL/bin/MysqLd --user=MysqL --basedir=/MysqL --datadir=/MysqL/data --initialize --pid-file=/MysqL/MysqL.pid --log_error=/MysqL/MysqL-error.log
控制台会打印root密码,记录下:_ervBerPW1?o  #使用命令查看初始化密码:cat /MysqL/MysqL-error.log |grep [email protected]

启动MysqL、设置root密码权限

ps -ef|grep MysqL #停掉已有的MysqL进程
service MysqLd start;
MysqL -uroot -p‘rghqvi;pO5yi‘ -hlocalhost --socket=/MysqL/MysqL.sock --port=3306
set password=password(‘Data‘);
#update MysqL.user set host=‘%‘ where user=‘root‘;
flush privileges;

创建应用数据库、应用帐号及赋权

会自动创建用户
create database rddb DEFAULT CHaraCTER SET utf8 COLLATE utf8_general_ci;
grant all privileges on rddb.* to rddb@‘%‘ identified by ‘cmsoft#098‘;
grant all privileges on MysqL.* to cmsoft#098‘;

常见安装错误

 1、启动错误
  Starting MysqL.. ERROR! The server quit without updating PID file (/data/file/MysqL/MysqL.pid).
    解决:
  chmod 755 MysqL-error.log
  echo "" > /MysqL/MysqL-error.log
  chown MysqL:MysqL  /MysqL/MysqL-error.log
  cd /MysqL/data
  rm -rf ibdata1 ib_logfile*
  service MysqLd start

2、ERROR 1146 (42S02): Table ‘MysqL.servers‘ doesn‘t exist
USE MysqL;
repair table servers
CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL,
`Host` char(64) NOT NULL,`Db` char(64) NOT NULL,
`Username` char(64) NOT NULL,
`Password` char(64) NOT NULL,
`Port` int(4) DEFAULT NULL,
`Socket` char(64) DEFAULT NULL,
`Wrapper` char(64) NOT NULL,
`Owner` char(64) NOT NULL,
PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘MysqL Foreign Servers table‘;

3、MysqL server PID file Could not be found![Failed]
    查看错误日志tail -f MysqL-error.log ;找(ERROR)发下是[ERROR] unkNown variable ‘expire_logs_day=30‘参数配置错误

4、Can‘t open the MysqL.plugin table. Please run MysqL_upgrade to create it.
    清除log文件、data目录下的文件;重新初始化:/MysqL/bin/MysqLd --user=MysqL --basedir=/MysqL --datadir=/MysqL/data --initialize --pid-file=/MysqL/MysqL.pid;service MysqLd restart;
5、#ERROR 1146 (42S02): Table ‘MysqL.servers‘ doesn‘t exist
  #错误解决,到data目录把servers表相关文件删除重新创建表
          cd /MysqL/data/MysqL;
          rm -rf servers*
USE MysqL;
repair table servers
CREATE TABLE `servers` (
`Server_name` char(64) NOT NULL,
`Host` char(64) NOT NULL,
`Username` char(64) NOT NULL,
`Password` char(64) NOT NULL,
`Port` int(4) DEFAULT NULL,
`Socket` char(64) DEFAULT NULL,
`Wrapper` char(64) NOT NULL,
`Owner` char(64) NOT NULL,
PRIMARY KEY (`Server_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘MysqL Foreign Servers table‘;
    6、 The server quit without updating PID file (/MysqL/MysqL.pid).[Failed]
    查看错误日志,发下3306端口被占用了
     [ERROR] Can‘t start server: Bind on TCP/IP port: Address already in use
    netstat -tnlp

集群(MGR)、故障恢复、版本升级




来自为知笔记(Wiz)

1.2二进制安装MySQL5.7

1.2二进制安装MySQL5.7

二进制安装MysqL5.7

环境准备

系统:Centos7

软件包:MysqL-5.7.30-linux-glibc2.12-x86_64.tar.gz

 

1. 安装相关包

[root@centos7 ~]#yum -y install libaio numactl-libs

 

2. 创建用户和组

[root@centos7 ~]#groupadd MysqL

[root@centos7 ~]#useradd -r -g MysqL -s /bin/false MysqL

 

3. 准备程序文件

[root@centos7 ~]#tar xfv MysqL-5.7.30-linux-glibc2.12-x86_64.tar.gz -C /usr/local

[root@centos7 ~]#cd /usr/local/

[root@centos7 local]#ln -sv MysqL-5.7.30-linux-glibc2.12-x86_64 MysqL

[root@centos7 local]#chown -R MysqL.MysqL /usr/local/MysqL/

[root@centos7 local]#chmod -R 755 /usr/local/MysqL/

 

4. 准备环境变量

[root@centos7 local]#echo 'PATH=/usr/local/MysqL/bin:$PATH' > /etc/profile.d/MysqL.sh

[root@centos7 local]#. /etc/profile.d/MysqL.sh

[root@centos7 local]# chmod +x /etc/profile.d/MysqL.sh

 

5. 创建数据库目录,修改权限

[root@centos7 local]#mkdir /data/MysqL -pv

mkdir: created directory ‘/data/MysqL’

[root@centos7 local]#chown -R MysqL:MysqL /data/MysqL/

 

 

6. 准备配置文件

[root@centos7 local]#cd /usr/local/MysqL/

[root@centos7 MysqL]#cp /etc/my.cnf{,.bak}

[root@centos7 MysqL]#vim /etc/my.cnf

[MysqLd]

datadir=/data/MysqL

socket=/var/lib/MysqL/MysqL.sock

explicit_defaults_for_timestamp=true

port=3306

character_set_server=utf8

user=MysqL

 

# disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run MysqLd under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

[MysqLd_safe]

#log-error=/var/log/mariadb/mariadb.log

log-error=/data/MysqL/MysqL.log

pid-file=/var/run/mariadb/mariadb.pid

 

[client]

port=3306

socket=/var/lib/MysqL/MysqL.sock

 

!includedir /etc/my.cnf.d

 

 

 

7. 创建配置文件中指定的路径并修改权限

[root@centos7 MysqL]#mkdir /var/lib/MysqL

[root@centos7 MysqL]#chown -R MysqL:MysqL /var/lib/MysqL/

[root@centos7 MysqL]#touch /var/lib/MysqL/MysqL.sock

[root@centos7 MysqL]#ll  /var/lib/MysqL

total 0

-rw-r--r-- 1 root root 0 Jul 18 23:42 MysqL.sock

[root@centos7 MysqL]#chmod guo+wr /var/lib/MysqL/MysqL.sock

[root@centos7 MysqL]#ll  /var/lib/MysqL

total 0

-rw-rw-rw- 1 root root 0 Jul 18 23:42 MysqL.sock

[root@centos7 MysqL]#touch /data/MysqL/MysqL.log

[root@centos7 MysqL]#ll /data/MysqL/

total 0

-rw-r--r-- 1 root root 0 Jul 18 23:43 MysqL.log

[root@centos7 MysqL]#chmod guo+rw /data/MysqL/MysqL.log

[root@centos7 MysqL]#ll /data/MysqL/MysqL.log

-rw-rw-rw- 1 root root 0 Jul 18 23:43 /data/MysqL/MysqL.log

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

下面是要做的,不然后面报错

[root@centos7 MysqL]#mkdir /var/run/mariadb

[root@centos7 MysqL]#chown -R MysqL:MysqL /var/run/mariadb/

[root@centos7 MysqL]#touch /var/run/mariadb/mariadb.pid

[root@centos7 MysqL]#ll /var/run/mariadb/

total 0

-rw-r--r-- 1 root root 0 Jul 18 23:44 mariadb.pid

[root@centos7 MysqL]#chmod guo+rw /var/run/mariadb/mariadb.pid

[root@centos7 MysqL]#ll /var/run/mariadb/

total 0

-rw-rw-rw- 1 root root 0 Jul 18 23:44 mariadb.pid

 

 

 

8. 初始化数据库文件并生成 root 空密码

[root@CentOS7 etc]cd /usr/local/MysqL

[root@centos7 MysqL]#rm -rf /data/MysqL/*

[root@centos7 MysqL]#./bin/MysqLd --initialize-insecure --datadir=/data/MysqL/ --user=MysqL&

 

9 . 启动MysqLd守护程序

[root@centos7 MysqL]#./bin/MysqLd_safe --user=MysqL --datadir=/data/MysqL &

 

10. 准备启动脚本,并启动服务

[root@centos7 MysqL]#cp /usr/local/MysqL/support-files/MysqL.server /etc/init.d/MysqLd

[root@centos7 MysqL]#chkconfig --add MysqLd

[root@centos7 MysqL]#systemctl start MysqLd.service

[root@centos7 MysqL]#ss -ntl

State      Recv-Q Send-Q              Local Address:Port                                                                   

LISTEN     0      80                           [::]:3306                                     [::]:*

 

11. 数据库的登录、查询,修改密码,退出数据库

[root@centos7 MysqL]#./bin/MysqL -uroot -p

[root@centos7 MysqL]# ./bin/MysqL -uroot -p

Enter password:   root密码为空,直接回车

Welcome to the MysqL monitor.  Commands end with ; or \g.

Your MysqL connection id is 2

Server version: 5.7.30 MysqL Community Server (GPL)

 

copyright (c) 2000, 2021, Oracle and/or its affiliates.

 

Oracle is a registered Trademark of Oracle Corporation and/or its

affiliates. Other names may be Trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MysqL>

 

MysqL> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| MysqL              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.00 sec)

 

MysqL> use MysqL;

MysqL> SELECT VERSION();

+-----------+

| VERSION() |

+-----------+

| 5.7.30    |

+-----------+

Database changed

 

 

修改用户密码

MysqL> alter user root@'localhost' identified by 'Mmagedu0!';

Query OK, 0 rows affected (0.00 sec)

 

MysqL> grant all privileges on *.* to root@'localhost';

Query OK, 0 rows affected (0.00 sec)

 

MysqL> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

MysqL> exit

Bye

 

12. 登录测试

添加PATH变量才能直接这样敲

[root@centos7 MysqL]#MysqL -uroot -p'Mmagedu0!'

MysqL: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MysqL monitor.  Commands end with ; or \g.

Your MysqL connection id is 3

Server version: 5.7.30 MysqL Community Server (GPL)

 

copyright (c) 2000, 2021, Oracle and/or its affiliates.

 

Oracle is a registered Trademark of Oracle Corporation and/or its

affiliates. Other names may be Trademarks of their respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

MysqL>

 

 

 

13. MysqL安全加固

在MysqL安装完成后,运行MysqL_secure_installation命令,提高安全性

[root@centos7 MysqL]# MysqL_secure_installation

Securing the MysqL server deployment.

Enter password for user root:

 

VALIDATE PASSWORD PLUGIN can be used to test passwords

and improve security. It checks the strength of password

and allows the users to set only those passwords which are

secure enough. Would you like to setup VALIDATE PASSWORD plugin?

 

Press y|Y for Yes, any other key for No: y

一路Y下来。

 

CenterOS7 安装Mysql8 及安装会遇到的问题

CenterOS7 安装Mysql8 及安装会遇到的问题

1.下载 MySQL 所需要的安装包

        网址:https://dev.mysql.com/downloads/mysql/

 

2.Select Operating System: 选择 Red Hat ,CentOS 是基于红帽的,Select OS Version: 选择 linux 7

 

3.选择 RPM Bundle 点击 Download

 

4.点击 No thanks, just start my download. 进行下载

 

5.下载好了

 

6.打开 VMware,选中要使用的虚拟机,点击开启此虚拟机

 

7.最小化虚拟机,不用管他了

 

8.打开 xshell,选择虚拟机 ip 所对应的会话,点击连接

 

9.连接成功

 

10.通过 rpm -qa | grep mariadb 命令查看 mariadb 的安装包

 

11.通过 rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps 命令装卸 mariadb

 

12.通过 rpm -qa | grep mariadb 命令再次查看 mariadb 的安装包

 

13.通过 cd /usr/local/ 命令进入根目录下的usr目录下的local目录,这个目录是放一些本地的共享资源的

 

14.通过 ll 命令查看一下当前目录下的目录结构

 

15.通过 mkdir mysql 命令 在当前目录下创建一个名为 mysql 的目录

 

16.通过 ll 命令查看一下当前目录下的目录结构,刚创建的 mysql 目录有了

 

17.通过 cd mysql 命令进入 mysql 目录

 

18.通过 ll 命令查看一下当前目录下的目录结构

 

19.点击 窗口 -->> 传输新建文件,通过 ftp 协议来把刚下载好的 mysql 安装包传输到 CentOS7 系统中

 

20.在左边找到你 mysql 安装包的下载目录

 

21.在你想要传输的文件上单机右键,点击传输

 

 

22.上传成功后,关闭 ftp 传输工具

 

 

23.通过 ll 命令查看一下当前目录下的目录结构

 

24.通过 tar -xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar  命令解压 tar 包

 

25.通过 clear 命令清一下屏

 

26.通过 rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm --nodeps --force 命令安装 common

 

27.通过 rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm --nodeps --force 命令安装 libs

 

28.通过 rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm --nodeps --force 命令安装 client

 

29.通过 rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm --nodeps --force 命令安装 server

 

30.通过 rpm -qa | grep mysql 命令查看 mysql 的安装包

 

此处注意:若不想数据库区分大小写,需在配置文件中加入一条配置

vim /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It''s default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#防止orderby报错 sql_mode=
''STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION''
#不区分表名大小写
log_bin_trust_function_creators=1 #skip-grant-tables

 

 

31.通过以下命令,完成对 mysql 数据库的初始化和相关配置

mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;

 

此处第一步若报错,则执行

 rpm -qa|grep libaio   

    运行该命令后发现系统中无该链接库文件

使用命令,yum install  libaio-devel.x86_64

安装成功后,继续运行数据库的初始化命令,提示成功。

 

此处第三步启动 mysql 若报错,则查看mysql日志

如果是yum安装,则默认是/var/log/mysqld.log

 

查看日志命令: tail -n 500 -f  /var/log/mysqld.log

 


32.通过 cat /var/log/mysqld.log | grep password 命令查看数据库的密码

 

33.通过 mysql -uroot -p 敲回车键进入数据库登陆界面

 

34.输入刚刚查到的密码,进行数据库的登陆,复制粘贴就行,MySQL 的登陆密码也是不显示的

 

35.通过 ALTER USER ''root''@''localhost'' IDENTIFIED WITH mysql_native_password BY ''root''; 命令来修改密码

 

36.通过 exit; 命令退出 MySQL,然后通过新密码再次登陆

 

37.通过以下命令,进行远程访问的授权

create user ''root''@''%'' identified with mysql_native_password by ''root'';
grant all privileges on *.* to ''root''@''%'' with grant option;
flush privileges;

 

此处修改密码若报错,则用以下语句

ALTER USER ''root''@''localhost'' IDENTIFIED BY ''*{your-password}*'';


 

38.通过 ALTER USER ''root''@''localhost'' IDENTIFIED BY ''root'' PASSWORD EXPIRE NEVER; 命令修改加密规则,MySql8.0 版本 和 5.0 的加密规则不一样,而现在的可视化工具只支持旧的加密方式。

 

 

39.通过 flush privileges; 命令刷新修该后的权限

 

40.通过 exit; 命令退出 MySQL

 

41.通过以下命令,关闭 firewall

systemctl stop firewalld.service;
systemctl disable firewalld.service;
systemctl mask firewalld.service;


42.通过 yum -y install iptables-services  命令安装 iptables 防火墙

 

43.通过以下命令启动设置防火墙

systemctl enable iptables;
systemctl start iptables;


44.通过 vim /etc/sysconfig/iptables 命令编辑防火墙,添加端口

 

45.点击 i 键进入插入模式

 

46.在相关位置,写入以下内容

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT


47.点击 ESC 键退出插入模式

 

48.点击 : 键,输入 wq 敲回车键保存退出,: 为英文状态下的

 

49.通过 systemctl restart iptables.service 命令重启防火墙使配置生效

 

50.通过 systemctl enable iptables.service 命令设置防火墙开机启动

 

51.通过 ifconfig 命令查看 ip

 

52.新建 SQLyog  的连接

 

53.连接成功



若可视化工具连接不上则进入mysql 

  • 打开终端,输入命令
    mysql -u root -p
    
  • 需要注意的是,MySQL 设置的密码中必须至少包含一个大写字母、一个小写字母、一个特殊符号、一个数字,至少 8 个字符;密码是在最开始安装 MySQL 的时候设置的,如果忘记了,上网查询解决方法。
  • 输入密码后,进入 >mysql 的命令行模式
       # 切换到 mysql 数据库
       use mysql;
       
       # 设置用户密码永不过期
       alter user ''root''@''localhost'' identified by ''your pwd'' password expire never; # 用「mysql_native_password」加密方式更新 root 用户密码 alter user ''root''@''localhost'' identified with mysql_native_password by ''your pwd''; # 刷新 flush privileges; 



 

CentOS 6.3 安装Mysql 遇到的问题

CentOS 6.3 安装Mysql 遇到的问题

wget –c http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-server-5.6.10-1.rhel5.x86_64.rpm/from/http://cdn.mysql.com

  1. 先通过wget下载安装包 

  2. 下载下来后文件名为cdn.mysql.com,更名为MySQL-server-5.6.10-1.rhel5.x86_64.rpm

  3. rpm -ivh MySQL-server-5.6.10-1.rhel5.x86_64.rpm 


安装过程中会出现以下错误:


CentOS6.3的32位操作系统默认会安装mysql-libs-5.1.61-4.el6.i686等lib文件,这样就会与MySQL5.6.10的安装文件冲突,第一次安装情况如下(conflicts with是冲突的意思):

[root@localhost bin]# rpm -ivh MySQL-server-5.6.10-1.linux_glibc2.5.i386.rpm

Preparing...  ########################################### [100%]

file /usr/share/mysql/charsets/README from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.6.10-1.linux_glibc2.5.i386 conflicts with file from package mysql-libs-5.1.61-4.el6.i686

解决办法如下:

先查看系统下有哪些包含MySQL字符串的包,再把查到的mysql-libs-5.1.61-4.el6.i686这个包卸载掉。

[root@localhost bin]# rpm -qa |grep -i mysql

mysql-libs-5.1.61-4.el6.i686

MySQL-client-5.6.10-1.linux_glibc2.5.i386

[root@localhost bin]# rpm -ev --nodeps mysql-libs-5.1.61-4.el6.i686

最后再重新执行安装命令即可:

[root@localhost bin]# rpm -ivh MySQL-server-5.6.10-1.linux_glibc2.5.i386.rpm


关于centos6.5 二进制安装mysql5.6 遇到的问题二进制安装mysql5.7的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于021_centos6.5二进制安装mysql.5.7.25、1.2二进制安装MySQL5.7、CenterOS7 安装Mysql8 及安装会遇到的问题、CentOS 6.3 安装Mysql 遇到的问题的相关知识,请在本站寻找。

本文标签: