因为Ubuntu Server上 wget比较慢,所以我是直接在windows用迅雷下载好,然后WinSCP上传到服务器的,看各自喜好了。

上正题。

包放在~/Download目录下,全部安装命令如下:

1、解压tar.gz

tar –xzf mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz

 

2、重命名解压的文件夹

mv mysql-5.6.10-linux-glibc2.5-x86_64 mysql

3、将mysql文件夹移动到/usr/local目录下

sudo mv ~/下载/mysql /usr/local

4、进入mysql目录

cd /usr/local/mysql

 

5、增加mysql用户组

sudo groupadd mysql

6、增加mysql用户

sudo useradd -r -g mysql mysql

 

7、将mysql文件夹own及grp变更为mysql

sudo chown -R mysql .

sudo chgrp -R mysql .

8、执行mysql安装脚本

sudo scripts/mysql_install_db --user=mysql

(若未安装libaio包,会有一个报错提示,安装libaio-dev后,再运行脚本即可。如果还是出错可以删除rm -rf /etc/my.cnf)

sudo apt-get install libaio-dev

9、将目录权限变更回来,仅保留data目录为mysql用户

sudo chown -R root .

sudo chown -R mysql data

10、将mysql配置文件拷贝到etc目录(全局配置)

注意:5.6版本的默认配置文件名称由原先的my-medium变更为了my-default。

sudo cp support-files/my-default.cnf /etc/my.cnf

 

11、启动mysql

sudo bin/mysqld_safe --user=mysql &

 

12、初始化mysql root用户密码

sudo bin/mysqladmin -u root password '密码文字'


#ps -A|grep mysql
   显示类似:
  1829 ?        00:00:00 mysqld_safe
   1876 ?        00:00:31 mysqld
  2.#kill -9 1829
  3.#kill -9 1876

 

13、复制mysql.server脚本到/etc/init.d(初始化服务,有些人喜欢改成mysqld,在这里改就可以)

sudo cp support-files/mysql.server /etc/init.d/mysql.server

 

14、查看mysql运行状态

sudo service mysql.server status
如果运行正常,会显示 MySQL running。

如果显示 not running,应该是前面没有启动服务,可直接用service mysql.server start启动

sudo service mysql.server [status|start|stop] 

 

15、让mysql开机启动[defaults],取消开机启动[remove]

sudo update-rc.d -f mysql.server defaults  [remove]

 

16、将mysql/bin/mysql命令加入到用户命令中,或将mysql/bin目录加入path

加入用户命令:

sudo ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql

加入环境变量:

export PATH=$PATH:/usr/local/mysql/bin

 

17、允许root用户远程登录

1>进入mysql: mysql –u root –p

2>改变数据库: use mysql;

3>从任意主机登录: grant all privileges on *.* to root@"%" identified by "密码文字" with grant option;

4>从指定主机登录: grant all privileges on *.* to root@"192.168.1.101" identified by "passw0rd" with grant option;

5>授权生效: flush privileges;

6>查看host为%授权是否添加: select * from user;

7>查看数据库字符集: show variables like 'character%';



启动完mysql后,我们接着可以测试一下,使用“mysql”命令来进入mysql数据库的控制台
$mysql -u root


在这里之所以用-u root是因为我现在是一般用户(firehare),如果不加-u root的话,mysql会以为是firehare在登录。注意,我在这里没有进入根用户模式,因为没必要。一般来说,对mysql中的数据库进行操作,根本没必要进入根用户模式,只有在设置时才有这种可能。

进入mysql之后,最要紧的就是要设置Mysql中的root用户密码了,否则,Mysql服务无安全可言了。
mysql> GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456";
如果需要使用root从其他机器远程访问可以使用
mysql> GRANT ALL PRIVILEGES ON *.* TO root@“%” IDENTIFIED BY "123456";
注意,我这儿用的是123456做为root用户的密码,但是该密码是不安全的,请大家最好使用大小写字母与数字混合的密码,且不少于8位。


配置文件参考:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[client]
port        = 3306
default-character-set=utf8
# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
character_set_server=utf8
lower_case_table_names=1
init_connect='SET NAMES utf8'

lower_case_table_names=1

max_connections=3000  
max_allowed_packet = 32M 

thread_cache_size = 16  
thread_concurrency = 8  

query_cache_size = 128M  

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
 join_buffer_size = 16M
 sort_buffer_size = 16M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[mysqldump]
quick
quote-names
max_allowed_packet = 32M  
  
[mysql]  
no-auto-rehash  


# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[client]
port        = 3306
default-character-set=utf8
# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
character_set_server=utf8
lower_case_table_names=1
init_connect='SET NAMES utf8'

lower_case_table_names=1

max_connections=3000  
max_allowed_packet = 32M 

thread_cache_size = 16  
thread_concurrency = 8  

query_cache_size = 128M  

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
 join_buffer_size = 16M
 sort_buffer_size = 16M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

[mysqldump]
quick
quote-names
max_allowed_packet = 32M  
  
[mysql]  
no-auto-rehash  


GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐