星空网 > 软件开发 > 操作系统

二进制包安装MySQL数据库

1.1二进制包安装MySQL数据库

1.1.1 安装前准备(规范)

 

 1 [root@Mysql_server ~]# mkdir -p /home/zhurui/tools ##创建指定工具包存放路径 2 [root@Mysql_server ~]# wget http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz ##下载二进制包 3 [root@Mysql_server tools]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz  ##解压Mysql包 4 [root@Mysql_server tools]# useradd -s /sbin/nologin -M mysql ##创建mysql用户 5 [root@Mysql_server tools]# id mysql 6 uid=501(mysql) gid=501(mysql) groups=501(mysql) 7 [root@Mysql_server ~]# mkdir /application/ 8 [root@Mysql_server home]# mv /home/zhurui/tools/mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32  9 [root@Mysql_server tools]# ll /application/10 total 411 drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.3212 [root@Mysql_server tools]# ln -s /application/mysql-5.5.32/ /application/mysql ##设置软链接13 [root@Mysql_server tools]# ll /application/14 total 415 lrwxrwxrwx. 1 root root  26 Dec 13 14:39 mysql -> /application/mysql-5.5.32/16 drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.3217 [root@Mysql_server tools]# ll /application/mysql/18 total 7619 drwxr-xr-x. 2 root root  4096 Dec 13 14:31 bin20 -rw-r--r--. 1 7161 wheel 17987 Jun 19 2013 COPYING21 drwxr-xr-x. 3 root root  4096 Dec 13 14:31 data22 drwxr-xr-x. 2 root root  4096 Dec 13 14:30 docs23 drwxr-xr-x. 3 root root  4096 Dec 13 14:31 include24 -rw-r--r--. 1 7161 wheel 7470 Jun 19 2013 INSTALL-BINARY25 drwxr-xr-x. 3 root root  4096 Dec 13 14:31 lib26 drwxr-xr-x. 4 root root  4096 Dec 13 14:31 man27 drwxr-xr-x. 10 root root  4096 Dec 13 14:31 mysql-test28 -rw-r--r--. 1 7161 wheel 2496 Jun 19 2013 README29 drwxr-xr-x. 2 root root  4096 Dec 13 14:31 scripts30 drwxr-xr-x. 27 root root  4096 Dec 13 14:31 share31 drwxr-xr-x. 4 root root  4096 Dec 13 14:31 sql-bench32 drwxr-xr-x. 3 root root  4096 Dec 13 14:31 support-files

 

1.1.2 初始化数据库

 

 1 [root@Mysql_server tools]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql ##初始化数据库 2 Installing MySQL system tables... 3 OK 4 Filling help tables... 5 OK 6 [root@Mysql_server tools]# ll /application/mysql/data/ ##查看初始化结果 7 total 12 8 drwx------. 2 mysql root 4096 Dec 13 14:45 mysql 9 drwx------. 2 mysql mysql 4096 Dec 13 14:45 performance_schema10 drwxr-xr-x. 2 mysql root 4096 Dec 13 14:31 test

 

1.1.3 授权Mysql管理数据库文件

1 [root@Mysql_server ~]# chown -R mysql.mysql /application/mysql/2 [root@Mysql_server ~]# ll /application/mysql3 lrwxrwxrwx. 1 mysql mysql 26 Dec 13 14:39 /application/mysql -> /application/mysql-5.5.32/

1.1.4 生成Mysql配置文件

1 [root@Mysql_server tools]# \cp /application/mysql/support-files/my-small.cnf /etc/my.cnf

1.1.5 配置启动Mysql

1 [root@Mysql_server tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server 2 [root@Mysql_server tools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld ##将生成的启动脚本拷贝到init.d目录下3 [root@Mysql_server tools]# chmod +x /etc/init.d/mysqld 

1.1.6 启动Mysql

1 [root@Mysql_server tools]# lsof -i :3306 ##查询Mysql服务是否开启2 [root@Mysql_server tools]# 3 [root@Mysql_server tools]# /etc/init.d/mysqld start ##启动Mysql服务4 Starting MySQL.... SUCCESS! 5 [root@Mysql_server tools]# lsof -i :33066 COMMAND PID USER  FD  TYPE DEVICE SIZE/OFF NODE NAME7 mysqld 2235 mysql  10u IPv4 22761   0t0 TCP *:mysql (LISTEN)8 [root@Mysql_server tools]# 

1.1.7 配置环境变量

方法1:

1 [root@Mysql_server tools]# cp /application/mysql/bin/* /usr/local/sbin/ ##方法1

方法2:

 

1 [root@Mysql_server tools]# tail -1 /etc/profile2 PATH="/application/mysql/bin:$PATH"  ##尾部添加如下行3 [root@Mysql_server tools]# source /etc/profile  ##使得配置生效

 

1.1.8 设置及更改密码

1 [root@Mysql_server tools]# mysqladmin -uroot password 123456  2 [root@Mysql_server tools]# mysqladmin -uroot -p123456 password zhurui

2.1 数据库管理

 

 1 [root@Mysql_server tools]# mysql -uroot -p 2 Enter password:  3 Welcome to the MySQL monitor. Commands end with ; or \g. 4 Your MySQL connection id is 8 5 Server version: 5.5.32 MySQL Community Server (GPL) 6  7 Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. 8  9 Oracle is a registered trademark of Oracle Corporation and/or its10 affiliates. Other names may be trademarks of their respective11 owners.12 13 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.14 15 mysql> show databases;  ##查看数据库;16 +--------------------+17 | Database      |18 +--------------------+19 | information_schema |20 | mysql       |21 | performance_schema |22 | test        |23 +--------------------+24 4 rows in set (0.00 sec)25 26 mysql> drop database test; ##删除test库;27 Query OK, 0 rows affected (0.00 sec)28 29 mysql> show databases;  30 +--------------------+31 | Database      |32 +--------------------+33 | information_schema |34 | mysql       |35 | performance_schema |36 +--------------------+37 3 rows in set (0.00 sec)38 39 mysql> select user,host from mysql.user; ##查看用户列表;40 +------+---------------+41 | user | host     |42 +------+---------------+43 | root | 127.0.0.1   |44 | root | ::1      |45 |   | Mysql\_server |46 | root | Mysql\_server |47 |   | localhost   |48 | root | localhost   |49 +------+---------------+50 6 rows in set (0.00 sec)51 52 mysql> drop user root@'::1'; ##删除无用用户53 Query OK, 0 rows affected (0.00 sec)54 55 mysql> drop user ''@'Mysql\_server';   ##对于大写、特殊字符删除不了,下面有介绍56 Query OK, 0 rows affected (0.00 sec)57 58 mysql> drop user ''@'localhost';  59 Query OK, 0 rows affected (0.01 sec)60 61 mysql> drop user 'root'@'Mysql\_server'; 对于大写、特殊字符删除不了,下面有介绍62 Query OK, 0 rows affected (0.00 sec)63 64 mysql> select user,host from mysql.user;65 +------+---------------+66 | user | host     |67 +------+---------------+68 | root | 127.0.0.1   |69 |   | Mysql\_server |70 | root | Mysql\_server |71 | root | localhost   |72 +------+---------------+73 4 rows in set (0.00 sec)74 对于大写、特殊字符删除不了解决办法:75 mysql> delete from mysql.user where user="" and host="Mysql\_server";76 Query OK, 1 row affected (0.02 sec)77 78 mysql> delete from mysql.user where user="root" and host="Mysql\_server";79 Query OK, 1 row affected (0.00 sec)80 81 mysql> select user,host from mysql.user; ##将无用用户删除以后,查看用户列表                82 +------+-----------+83 | user | host   |84 +------+-----------+85 | root | 127.0.0.1 |86 | root | localhost |87 +------+-----------+88 2 rows in set (0.00 sec)89 mysql> flush privileges; ##最后使得权限生效90 Query OK, 0 rows affected (0.00 sec)

创建用户sql语句:

 

1 mysql> grant all on *.* to 'root'@'localhost' identified by '123456' with grant option;flush privileges;

 




原标题:二进制包安装MySQL数据库

关键词:MYSQL

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

苏州跨境电子商务协会:https://www.goluckyvip.com/tag/41607.html
苏州悠飞智能科技:https://www.goluckyvip.com/tag/41609.html
苏州紫博蓝:https://www.goluckyvip.com/tag/41610.html
苏州综试区:https://www.goluckyvip.com/tag/41611.html
速发跨境供应链:https://www.goluckyvip.com/tag/41612.html
速丰国际货运代理:https://www.goluckyvip.com/tag/41613.html
重庆品胜科技与星苹台达成合作 助力部队现代化后勤建设 :https://www.kjdsnews.com/a/1836523.html
回乡创业,不知道干什么,能否推荐几个农村老家创业的好项目?:https://www.vstour.cn/a/365177.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流