中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

mysql 數據庫的安裝之 二 二進制安裝

發布時間:2020-05-18 13:20:36 來源:網絡 閱讀:1052 作者:ahtornado 欄目:數據庫

#二進制安裝mysql,直接解壓初始化數據庫就可以了

1.創建用戶和組

[root@Lnmp tools]#useradd mysql -s /sbin/nologin/ -M

2.解壓安裝包

[root@Lnmp tools]#tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz 


[root@Lnmp tools]#mv mysql-5.5.32-linux2.6-x86_64 mysql

[root@Lnmp tools]#mv mysql /application/ 

#獨立安裝數據庫到此結束。

[root@Lnmp tools]# mkdir -p /application/mysql/data/


[root@Lnmp tools]#chown -R mysql.mysql /application/mysql/data


3.初始化數據庫

[root@Lnmp tools]# cd /application/mysql/

[root@Lnmp mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data/

WARNING: The host 'Lnmp' could not be looked up with resolveip.

This probably means that your libc libraries are not 100 % compatible

with this binary MySQL version. The MySQL daemon, mysqld, should work

normally with the exception that host name resolving will not work.

This means that you should use IP addresses instead of hostnames

when specifying MySQL privileges !

Installing MySQL system tables...

OK

Filling help tables...

OK


[root@Lnmp mysql]# \cp support-files/mysql.server /etc/init.d/mysqld


[root@Lnmp mysql]#cp support-files/my-small.cnf /etc/my.cnf  #指定配置文件


#如果不指定則,啟動時出現:

ERROR 2002 (HY000):Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock/(2)


4.啟動Mysql:

[root@Lnmp mysql]# /etc/init.d/mysqld start 

/etc/init.d/mysqld: line 276: cd: /usr/local/mysql: No such file or directory

Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

如果不成功則修改下面:

[root@Lnmp mysql]# vi /etc/init.d/mysqld  +46

basedir=/application/mysql

datadir=/application/mysql/data


[root@Lnmp mysql]# /etc/init.d/mysqld start

Starting MySQL.. SUCCESS! 


#登錄

#mysql

出現下面錯誤:

#-bash:mysql:command not found

mysql 對應的路徑不在path目錄下面

使用全路徑進入mysql:

/application/mysql/bin/mysql

或者在文件最后加上:

vi /etc/profile

PATH="/application/mysql/bin/:$PATH"

#. /etc/profile   #使之生效

mysql>


#設置密碼,不要在mysql>  下面設置密碼,在#后面設置密碼

/application/mysql/bin/mysqladmin -u  root password 'passwd123'

#重新登錄


mysql -u root -p

passwd123


5.數據優化:

select version();         #查看數據庫版本

select user();            #查看當前的用戶

mysql> show databases;    #查看數據庫

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

| test               |

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


mysql>drop database test; #安全設置,刪除沒有用的數據庫

#最終優化為:

mysql> show databases;

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

| Database           |

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

| information_schema |

| mysql              |

| performance_schema |

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

mysql> select user,host from mysql.user;  #查詢表中的用戶

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

| user | host      |

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

| root | 127.0.0.1 |

| root | ::1       |

|      | Lnmp      |

| root | Lnmp      |

|      | localhost |

| root | localhost |

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

mysql>delete from mysql.user where(host="Lnmp");

mysql>delete from mysql.user where(host="::1");

mysql> drop user ""@localhost;

#最終優化為:

mysql> select user,host from mysql.user;

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

| user | host      |

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

| root | 127.0.0.1 |

| root | localhost |

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

最后:

flush privileges;


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

宜宾市| 湖口县| 三江| 仁怀市| 西丰县| 天全县| 大荔县| 广灵县| 清原| 辰溪县| 米脂县| 云龙县| 奎屯市| 白河县| 广丰县| 留坝县| 泰州市| 普格县| 彩票| 缙云县| 香格里拉县| 兴化市| 扶绥县| 微博| 门头沟区| 政和县| 高青县| 武夷山市| 罗田县| 龙州县| 阳西县| 商南县| 镇安县| 吉首市| 鄱阳县| 黑山县| 马边| 措勤县| 神木县| 连江县| 黔东|