lnmp服务一mysql部署

1.软件包信息

[root@lnmp ~]# ll mysql-5.5.32-linux2.6-x86_64.tar.gz 
-rw-r--r--. 1 root root 186722932 Aug  5 22:10 mysql-5.5.32-linux2.6-x86_64.tar.gz

2.创建用户

[root@lnmp ~]# useradd mysql -s /sbin/nologin -M

3.二进制安装mysql

3.1解压安装包

[root@lnmp ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz

3.2移动目录,创建软链接

[root@lnmp ~]# mv mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql-5.5.32
[root@lnmp ~]# ln -s /usr/local/mysql-5.5.32/ /application/mysql

4.数据库初始化

4.1授权data目录

[root@lnmp ~]# chown -R mysql:mysql /application/mysql/data/

4.2初始化data

[root@lnmp ~]# cd /application/mysql/
[root@lnmp mysql]# yum install libaio-devel -y
[root@lnmp mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/

4.3复制配置文件

[root@lnmp mysql]# \cp support-files/my-small.cnf /etc/my.cnf

4.4修改自带的管理脚本

[root@lnmp mysql]# \cp support-files/mysql.server /etc/init.d/mysqld
[root@lnmp mysql]# vi /etc/init.d/mysqld 
     46 basedir=/application/mysql/
     47 datadir=/application/mysql/data
[root@lnmp mysql]# chmod +x /etc/init.d/mysqld 
[root@lnmp mysql]# chkconfig --add /etc/init.d/mysqld 

5.启动数据库

[root@lnmp mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS! 

6.初始化数据库密码

[root@lnmp mysql]# tail -1 /etc/profile
PATH=/application/mysql/bin/:$PATH
[root@lnmp mysql]# source /etc/profile
[root@lnmp mysql]# mysql_secure_installation 
回车 设置密码
y
n
y
y

7.登录mysql测试

[root@lnmp mysql]# mysql -uroot -p000000
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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> 

猜你喜欢

转载自blog.csdn.net/liang_operations/article/details/81454555