日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

二进制包 mysql_二进制包安装MySQL数据库

發布時間:2023/12/10 数据库 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 二进制包 mysql_二进制包安装MySQL数据库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.1二進制包安裝MySQL數據庫

1.1.1 安裝前準備(規范)

[root@Mysql_server ~]# mkdir -p /home/zhurui/tools? ##創建指定工具包存放路徑

[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? ##下載二進制包

[root@Mysql_server tools]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz? ##解壓Mysql包

[root@Mysql_server tools]# useradd -s /sbin/nologin -M mysql? ##創建mysql用戶

[root@Mysql_server tools]# id mysql

uid=501(mysql) gid=501(mysql) groups=501(mysql)

[root@Mysql_server ~]# mkdir /application/

[root@Mysql_server home]# mv /home/zhurui/tools/mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32

[root@Mysql_server tools]# ll /application/

total 4

drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32

[root@Mysql_server tools]# ln -s /application/mysql-5.5.32/ /application/mysql? ##設置軟鏈接

[root@Mysql_server tools]# ll /application/

total 4

lrwxrwxrwx.? 1 root root? 26 Dec 13 14:39 mysql -> /application/mysql-5.5.32/

drwxr-xr-x. 13 root root 4096 Dec 13 14:31 mysql-5.5.32

[root@Mysql_server tools]# ll /application/mysql/

total 76

drwxr-xr-x.? 2 root root? 4096 Dec 13 14:31 bin

-rw-r--r--.? 1 7161 wheel 17987 Jun 19? 2013 COPYING

drwxr-xr-x.? 3 root root? 4096 Dec 13 14:31 data

drwxr-xr-x.? 2 root root? 4096 Dec 13 14:30 docs

drwxr-xr-x.? 3 root root? 4096 Dec 13 14:31 include

-rw-r--r--.? 1 7161 wheel? 7470 Jun 19? 2013 INSTALL-BINARY

drwxr-xr-x.? 3 root root? 4096 Dec 13 14:31 lib

drwxr-xr-x.? 4 root root? 4096 Dec 13 14:31 man

drwxr-xr-x. 10 root root? 4096 Dec 13 14:31 mysql-test

-rw-r--r--.? 1 7161 wheel? 2496 Jun 19? 2013 README

drwxr-xr-x.? 2 root root? 4096 Dec 13 14:31 scripts

drwxr-xr-x. 27 root root? 4096 Dec 13 14:31 share

drwxr-xr-x.? 4 root root? 4096 Dec 13 14:31 sql-bench

drwxr-xr-x.? 3 root root? 4096 Dec 13 14:31 support-files

1.1.2 初始化數據庫

[root@Mysql_server tools]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql? ##初始化數據庫

Installing MySQL system tables...

OK

Filling help tables...

OK

[root@Mysql_server tools]# ll /application/mysql/data/? ##查看初始化結果

total 12

drwx------. 2 mysql root? 4096 Dec 13 14:45 mysql

drwx------. 2 mysql mysql 4096 Dec 13 14:45 performance_schema

drwxr-xr-x. 2 mysql root? 4096 Dec 13 14:31 test

1.1.3 授權Mysql管理數據庫文件

[root@Mysql_server ~]# chown -R mysql.mysql /application/mysql/

[root@Mysql_server ~]# ll /application/mysql

lrwxrwxrwx. 1 mysql mysql 26 Dec 13 14:39 /application/mysql -> /application/mysql-5.5.32/

1.1.4 生成Mysql配置文件

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

1.1.5 配置啟動Mysql

[root@Mysql_server tools]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /application/mysql/support-files/mysql.server

[root@Mysql_server tools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld? ##將生成的啟動腳本拷貝到init.d目錄下

[root@Mysql_server tools]# chmod +x /etc/init.d/mysqld

1.1.6 啟動Mysql

[root@Mysql_server tools]# lsof -i :3306? ##查詢Mysql服務是否開啟

[root@Mysql_server tools]#

[root@Mysql_server tools]# /etc/init.d/mysqld start? ##啟動Mysql服務

Starting MySQL.... SUCCESS!

[root@Mysql_server tools]# lsof -i :3306

COMMAND? PID? USER? FD? TYPE DEVICE SIZE/OFF NODE NAME

mysqld? 2235 mysql? 10u? IPv4? 22761? ? ? 0t0? TCP *:mysql (LISTEN)

[root@Mysql_server tools]#

1.1.7 配置環境變量

方法1:

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

方法2:

[root@Mysql_server tools]# tail -1 /etc/profile

PATH="/application/mysql/bin:$PATH"? ##尾部添加如下行

[root@Mysql_server tools]# source /etc/profile? ? ##使得配置生效

1.1.8 設置及更改密碼

[root@Mysql_server tools]# mysqladmin -uroot password 123456

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

2.1 數據庫管理

[root@Mysql_server tools]# mysql -uroot -p

Enter password:

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> show databases;? ##查看數據庫;

+--------------------+

| Database? ? ? ? ? |

+--------------------+

| information_schema |

| mysql? ? ? ? ? ? ? |

| performance_schema |

| test? ? ? ? ? ? ? |

+--------------------+

4 rows in set (0.00 sec)

mysql> drop database test;? ##刪除test庫;

Query OK, 0 rows affected (0.00 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? ? ? ? ? |

|? ? ? | Mysql\_server |

| root | Mysql\_server |

|? ? ? | localhost? ? |

| root | localhost? ? |

+------+---------------+

6 rows in set (0.00 sec)

mysql> drop user root@'::1';? ##刪除無用用戶

Query OK, 0 rows affected (0.00 sec)

mysql> drop user ''@'Mysql\_server';? ? ? ##對于大寫、特殊字符刪除不了,下面有介紹

Query OK, 0 rows affected (0.00 sec)

mysql> drop user ''@'localhost';

Query OK, 0 rows affected (0.01 sec)

mysql> drop user 'root'@'Mysql\_server';? 對于大寫、特殊字符刪除不了,下面有介紹

Query OK, 0 rows affected (0.00 sec)

mysql> select user,host from mysql.user;

+------+---------------+

| user | host? ? ? ? ? |

+------+---------------+

| root | 127.0.0.1? ? |

|? ? ? | Mysql\_server |

| root | Mysql\_server |

| root | localhost? ? |

+------+---------------+

4 rows in set (0.00 sec)

對于大寫、特殊字符刪除不了解決辦法:

mysql> delete from mysql.user where user="" and host="Mysql\_server";

Query OK, 1 row affected (0.02 sec)

mysql> delete from mysql.user where user="root" and host="Mysql\_server";

Query OK, 1 row affected (0.00 sec)

mysql> select user,host from mysql.user;? ##將無用用戶刪除以后,查看用戶列表

+------+-----------+

| user | host? ? ? |

+------+-----------+

| root | 127.0.0.1 |

| root | localhost |

+------+-----------+

2 rows in set (0.00 sec)

mysql> flush privileges;? ##最后使得權限生效

Query OK, 0 rows affected (0.00 sec)

創建用戶sql語句:

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

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL http://www.linuxidc.com/Linux/2014-05/102351.htm

總結

以上是生活随笔為你收集整理的二进制包 mysql_二进制包安装MySQL数据库的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。