[mysql 1]linux mysal 安装

[mysql]linux mysal 安装

作者:flymaster

qq:908601287

blog:http://www.cnblogs.com/flymaster500/

mkdir /home/fly/tools
cd /fly/tools/
rz -y #上传
ls
useradd -s /sbin/nologin -M mysql #建用户
id mysql
tar xf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz#解压
mkdir /application
mv mysql-5.6.39-linux-glibc2.12-x86_64 /application/ #相当于编译安装 速度块
cd /application/
ln -s /application/mysql-5.6.39-linux-glibc2.12-x86_64 /application/mysql #软连接
ll /application/mysql/
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql #初始化
yum install -y perl perl-devel #根据提示看是否需要这个包
chown -R mysql.mysql /application/mysql #配置权限
vi /etc/hosts #解析主机名 echo "59.215.233.122 localhost" >>/etc/hosts
yum install -y libaio* #看提示是否需要这2个包
yum install -y libnuma*
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql #安装成功会返回2个ok
echo $? #看是否成功 返回0成功
/application/mysql//bin/mysqld_safe &(启动)
#配置/etc/init.d/mysqld 启动
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server
cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start #启动
Starting MySQL.Logging to '/application/mysql/data/mysql_66.err'.
... SUCCESS!
lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 1492 mysql 10u IPv6 13492 0t0 TCP *:mysql (LISTEN)
cp /application/mysql/bin/* /usr/local/sbin/
cp /application/mysql/bin/* /usr//bin/
mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.6.39 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> exit
Bye
ch 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 |
| test |
+--------------------+
4 rows in set (0.05 sec)

mysql> drop database test;
Query OK, 0 rows affected (0.10 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | mysql\_66 |
| root | mysql\_66 |
+------+-----------+
6 rows in set (0.00 sec)

mysql> drop user 'root'@'::1';
Query OK, 0 rows affected (0.04 sec)

mysql> drop user ''@'localhost';
Query OK, 0 rows affected (0.00 sec)


mysql> drop user ''@'mysql\_66';
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
| root | mysql\_66 |
+------+-----------+
3 rows in set (0.00 sec)

mysql> drop user 'root'@'mysql\_66';
Query OK, 0 rows affected (0.03 sec)

For server side help, type 'help contents'

mysql> flush privileges
-> ;
Query OK, 0 rows affected (0.00 sec)

作者:flymaster

qq:908601287

blog:http://www.cnblogs.com/flymaster500/

原文地址:https://www.cnblogs.com/flymaster500/p/10155652.html