大数据教程(2.4):Linux系统安装mysql5.6.40

    博主今天分享在centos6.9的minimal版本上安装mysql5.6.40的全过程,此过程相当繁琐,请大家耐心一步步安装。

    安装步骤:

(1)下载mysql版本mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz,地址:https://dev.mysql.com/downloads/mysql/

611ee3622d0e38e8c0a7f9ad2df1c419232.jpg

(2)上传mysql压缩包

b656c00ab22e26e4d96f673da448112f665.jpg

(3)解压mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz到/usr/local目录

b24ec5d481b0c4ec2938a4a8044ce55f8e7.jpg

(4)重命名解压包

019e82feba49147ddc0bb30cd671fb5309a.jpg

(5)创建mysql用户,并且设置密码(123456)

1068d97031b040481f24a299f3c3bcf79c5.jpg

(6)将mysql目录的权限授给mysql用户和mysql组

2482bd9a6537c9761ed6576185b1077d636.jpg

(7)切换到mysql用户,执行安装

0cc6a8df1d4a7371e47950a9b177ad947b0.jpg

fa8590c995586979d63f7b92c6abeb1409a.jpg

(8)由于上一步安装时报错“-bash: /usr/local/mysql/scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录”,需要切换到root用户,安装perl以及perl-devel,执行命令:yum -y install perl perl-devel

e1d141877e5e96f3c10dcf0cf79d0e6a489.jpg

(9)继续安装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”

3a7c82d98dd9c8875626b1fe03f14b67ac9.jpg

(10)由于上一步报错缺少libaio相关包,此处需要安装libaio相关包

7c45c4f52eb0fc49f4872f8d8eefed02778.jpg

bb314dc264d00bae5bcfa8d2b5e4404c0f4.jpg

(11)继续执行安装mysql命令,报错缺少libnuma.so.1相关包

0adb2ea515b7e3c487e26cfa2c5149a011b.jpg

(12)由于上一步骤报错缺少“libnuma.so.1”,经分析时缺少numactl相关包,此处需要安装numactl相关包

6b1eb678edc650dc71aa8d061dbd5d8397c.jpg

2b9fd1a0e68ba3d2b312e84687becc37bc8.jpg

(13)继续执行安装mysql命令,安装成功

9b6ddf465e73cf1dd0e0276a5114eac6595.jpg

(14)断开secureCRT连接,拷贝出安装mysql命令后的提示(此步骤很重要,内含有mysql重要信息)

[root@centos-aaron-03 ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Installing MySQL system tables...2018-07-09 07:09:32 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-07-09 07:09:32 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-07-09 07:09:32 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.40) starting as process 1792 ...
2018-07-09 07:09:32 1792 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-07-09 07:09:32 1792 [Note] InnoDB: The InnoDB memory heap is disabled
2018-07-09 07:09:32 1792 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-07-09 07:09:32 1792 [Note] InnoDB: Memory barrier is not used
2018-07-09 07:09:32 1792 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-07-09 07:09:32 1792 [Note] InnoDB: Using Linux native AIO
2018-07-09 07:09:32 1792 [Note] InnoDB: Using CPU crc32 instructions
2018-07-09 07:09:32 1792 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-07-09 07:09:32 1792 [Note] InnoDB: Completed initialization of buffer pool
2018-07-09 07:09:32 1792 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-07-09 07:09:32 1792 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-07-09 07:09:32 1792 [Note] InnoDB: Database physically writes the file full: wait...
2018-07-09 07:09:32 1792 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-07-09 07:09:32 1792 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-07-09 07:09:32 1792 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-07-09 07:09:32 1792 [Warning] InnoDB: New log files created, LSN=45781
2018-07-09 07:09:32 1792 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-07-09 07:09:32 1792 [Note] InnoDB: Doublewrite buffer created
2018-07-09 07:09:32 1792 [Note] InnoDB: 128 rollback segment(s) are active.
2018-07-09 07:09:32 1792 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-07-09 07:09:32 1792 [Note] InnoDB: Foreign key constraint system tables created
2018-07-09 07:09:32 1792 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-07-09 07:09:32 1792 [Note] InnoDB: Tablespace and datafile system tables created.
2018-07-09 07:09:32 1792 [Note] InnoDB: Waiting for purge to start
2018-07-09 07:09:32 1792 [Note] InnoDB: 5.6.40 started; log sequence number 0
2018-07-09 07:09:32 1792 [Note] Binlog end
2018-07-09 07:09:32 1792 [Note] InnoDB: FTS optimize thread exiting.
2018-07-09 07:09:32 1792 [Note] InnoDB: Starting shutdown...
2018-07-09 07:09:34 1792 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2018-07-09 07:09:34 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-07-09 07:09:34 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-07-09 07:09:34 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.40) starting as process 1814 ...
2018-07-09 07:09:34 1814 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-07-09 07:09:34 1814 [Note] InnoDB: The InnoDB memory heap is disabled
2018-07-09 07:09:34 1814 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-07-09 07:09:34 1814 [Note] InnoDB: Memory barrier is not used
2018-07-09 07:09:34 1814 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-07-09 07:09:34 1814 [Note] InnoDB: Using Linux native AIO
2018-07-09 07:09:34 1814 [Note] InnoDB: Using CPU crc32 instructions
2018-07-09 07:09:34 1814 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-07-09 07:09:34 1814 [Note] InnoDB: Completed initialization of buffer pool
2018-07-09 07:09:34 1814 [Note] InnoDB: Highest supported file format is Barracuda.
2018-07-09 07:09:34 1814 [Note] InnoDB: 128 rollback segment(s) are active.
2018-07-09 07:09:34 1814 [Note] InnoDB: Waiting for purge to start
2018-07-09 07:09:34 1814 [Note] InnoDB: 5.6.40 started; log sequence number 1625977
2018-07-09 07:09:34 1814 [Note] Binlog end
2018-07-09 07:09:34 1814 [Note] InnoDB: FTS optimize thread exiting.
2018-07-09 07:09:34 1814 [Note] InnoDB: Starting shutdown...
2018-07-09 07:09:36 1814 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h centos-aaron-03 password 'new-password'

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/local/mysql/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/local/mysql/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

(15)切换到root用户,复制并修改配置文件,添加msql服务

092be91004f52403eb65d79146803e9a391.jpg

(16)修改配置文件

afbfbdaafde1fe328e5fc9460bd477d1c68.jpg

(17)配置mysql的环境变量,并且重新加载配置文件

vi /etc/profile
source /etc/profile

351d90652795984102ed3955a4d90743eea.jpg

(18)切换到mysql用户,启用mysql,配置mysql开机自动启动

f2a481d98848f17547e40dff376f2470822.jpg

(19)设置mysql的root用户密码123456

8eec4610f8d2bf4183481ae345d5231a385.jpg

(20)用root用户登录mysql

2fccd04f483e49365576a8c54d0b1583094.jpg

(注意:当执行quit退出再重新登录,可能报ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)异常,解决方法如下: 

方法一: 
(1)关闭mysql
[mysql@localhost ~]$  service mysql stop

(2)屏蔽权限
[mysql@localhost ~]$  mysqld_safe --skip-grant-table
屏幕出现: Starting demo from …..

(3)新开起一个终端输入
[mysql@localhost ~]$   mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql>quit

方法二: 
(1)关闭mysql
[mysql@localhost ~]$  service mysql stop

(2)屏蔽权限
[mysql@localhost ~]$  mysqld_safe --skip-grant-table
屏幕出现: Starting demo from …..

(3)新开起一个终端输入
[mysql@localhost ~]$   mysql -u root mysql
mysql> delete from user where USER='';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql>quit

(21)让远程客户端可以连接mysql服务器

使用 mysql库 :
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

查看用户表 :
mysql> SELECT `Host`,`User` FROM user;

更新用户表 :
mysql> UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;

注:host=localhost 那此用户就不具有远程访问权限,修改为%的意思是允许所有的ip远程访问,如果需要指定具体的某个ip就写上具体的ip即可

强制刷新权限 :
mysql> flush privileges;

或者通过授权的方式:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'   IDENTIFIED BY '123456'  WITH GRANT OPTION; 

如果需要指定具体的某个ip就把%替换成具体的ip:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.194.20'   IDENTIFIED BY '123456'  WITH GRANT OPTION; 

别忘记强制刷新权限 :
mysql> flush privileges;

查看端口sql:
mysql>  show global variables like 'port';  

97bb35d6cc66520f06c446792a563c800f2.jpg

e7ac2cb88ef5b20c56be81f332eb8778710.jpg

dfb5eef1d4524f2222f1a1adf6960d61fe8.jpg

545b4931c463789243996dbb974e124263e.jpg

2f19b33902d27899c152d93ff6017ae6acb.jpg

最后总结:centos最小化安装的版本安装mysql步骤真够多的,缺包太多;建议不熟悉的小白们还是使用其他版本的centos安装。

转载于:https://my.oschina.net/u/2371923/blog/1842455

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值