LNMP架构MySQL源码包的安装

1.首先先获得mysql的源码包,解压

在这里插入图片描述
在这里插入图片描述

2.安装包的依赖性

yum install cmake-2.8.12.2-4.el6.x86_64.rpm  -y
yum install -y gcc gcc-c++ 
yum install -y ncurses-devel
yum install -y bison

3.添加配置

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql \
-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data \
 -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock \
 -DWITH_MYISAM_STORAGE_ENGINE=1 \
 -DWITH_INNOBASE_STORAGE_ENGINE=1 \
 -DDEFAULT_CHARSET=utf8  \
 -DDEFAULT_COLLATION=utf8_general_ci  \
 -DEXTRA_CHARSETS=all  \
 -DWITH_BOOST=boost/boost_1_59_0/
具体配置信息如下

在这里插入图片描述

重新编译时,需要清除旧的对象文件和缓存信息
make clean
rm -f CmakeCache.txt

4.编译安装

make && make install 
编译安装时间要一段时间,耐心等待即可

在这里插入图片描述
在这里插入图片描述

制作启动脚本修改配置文件

   48  cd mysql-5.7.17/
   49  cd support-files/
   50  cp my-default.cnf /etc/my.cnf
   51  vim /etc/my.cnf

在这里插入图片描述

   69  cd mysql-5.7.17/
   70  cd support-files/
   71  ls
   72  cp mysql.server /etc/init.d/mysqld

配置环境变量

 vim ~/.bash_profile 
 PATH=$PATH:$HOME/bin
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
 source ~/.bash_profile 

修改权限,添加用户

54  groupadd mysql -g 27
55  useradd -u 27 -g 27 mysql
57  chown mysql.mysql /usr/local/lnmp/mysql/ -R
63  chown root -R /usr/local/lnmp/mysql/
65  chown mysql /usr/local/lnmp/mysql/data/ -R
    chmod 777 /etc/init.d/mysqld 

启动mysql

 /etc/init.d/mysqld start

在这里插入图片描述

初始化

 mysqld --user=mysql --initialize
[root@server1 data]# mysqld --user=mysql --initialize
2019-04-29T16:35:46.560391Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-04-29T16:35:46.560418Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2019-04-29T16:35:46.560421Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2019-04-29T16:35:48.670900Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-04-29T16:35:49.175266Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-04-29T16:35:49.480825Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d8b6be8a-6a9c-11e9-9e48-525400410a47.
2019-04-29T16:35:49.645898Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-04-29T16:35:49.646316Z 1 [Note] A temporary password is generated for root@localhost: h(Yly+Al94ql  ##初始化密码

重置密码

[root@server1 ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root:    ##即刚才初始化的密码
Error: Access denied for user 'root'@'localhost' (using password: YES)
[root@server1 ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 
Error: Access denied for user 'root'@'localhost' (using password: YES)
[root@server1 ~]# mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 

The existing password for the user account root has expired. Please set a new password.

New password: 

Re-enter new password: 

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: No
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : 

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : 

 ... skipping.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : 

 ... skipping.
All done! 

登陆测试

[root@server1 ~]# mysql -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.7.17 Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> quit
Bye
没问题!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值