MySQL入门篇(一)之MySQL部署
生活随笔
收集整理的這篇文章主要介紹了
MySQL入门篇(一)之MySQL部署
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
-
MySQL 二進(jìn)制免編譯安裝
(1)下載二進(jìn)制免編譯版本mysql 5.6.35
[root@localhost tools]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz (2)增加mysql運(yùn)行用戶 [root@localhost tools]# useradd -s /sbin/nologin -M mysql (3)解壓并移動(dòng)Mysql到指定的安裝路徑 [root@localhost tools]# tar -zxf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [root@localhost tools]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql-5.6.35 (4)創(chuàng)建軟連接并更改目錄所屬 [root@localhost tools]# ln -sv /usr/local/mysql-5.6.35 /usr/local/mysql ‘/usr/local/mysql’ -> ‘/usr/local/mysql-5.6.35’ [root@localhost mysql]# chown -R mysql.mysql /usr/local/mysql (5)初始化Mysql [root@localhost mysql]# scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql (6)拷貝Mysql啟動(dòng)腳本,并修改腳本權(quán)限啟動(dòng) [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@localhost mysql]# chmod 755 /etc/init.d/mysqld [root@localhost mysql]# vim /etc/init.d/mysqld basedir=/usr/local/mysql datadir=/usr/local/mysql/data [root@localhost mysql]# cp support-files/my-default.cnf /etc/my.cnf [root@localhost mysql]# /etc/init.d/mysqld start Starting MySQL.Logging to '/usr/local/mysql/data/localhost.err'. ... SUCCESS! [root@localhost mysql]# netstat -tulnp |grep 3306 tcp6 0 0 :::3306 :::* LISTEN 62679/mysqld (7)加入開機(jī)啟動(dòng),測(cè)試登錄 [root@localhost mysql]# chkconfig --add mysqld [root@localhost mysql]# chkconfig mysqld on [root@localhost mysql]# export PATH=/usr/local/mysql/bin/:$PATH [root@localhost mysql]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.35 MySQL Community Server (GPL)Copyright (c) 2000, 2016, 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> quit; (8)mysql安全設(shè)置 [root@localhost mysql]# mysqladmin -uroot password '123456' //配置mysql的root用戶密碼 Warning: Using a password on the command line interface can be insecure. [root@localhost mysql]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@localhost mysql]# mysql -uroot -p123456 -e "show databases;" Warning: Using a password on the command line interface can be insecure. +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+[root@localhost mysql]# mysql -uroot -p //清理無用的Mysql用戶和庫 Enter password: mysql> select user,host from mysql.user; +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | ::1 | | | localhost | | root | localhost | +------+-----------+ 4 rows in set (0.01 sec)mysql> drop user "root"@"::1"-> ; Query OK, 0 rows affected (0.00 sec)mysql> drop user ""@"localhost"; Query OK, 0 rows 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)有時(shí)使用drop命令刪除不了用戶,可能是大寫或者是特殊的Linux主機(jī)名導(dǎo)致的,如下: mysql> drop user ''@'MySQL'; ERROR 1396 (HY000): Operation DROP USER failed for ''@'mysql'解決辦法如下: mysql> delete from mysql.user where user='' and host='MySQL'; mysql> flush privileges;?
轉(zhuǎn)載于:https://www.cnblogs.com/linuxk/p/9365938.html
總結(jié)
以上是生活随笔為你收集整理的MySQL入门篇(一)之MySQL部署的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Unity中调用手机中的粘贴功能
- 下一篇: linu下未编译的mysql安装包