ubuntu14.04安装mysql5.6

来源:互联网 发布:格式化u盘恢复数据 编辑:程序博客网 时间:2024/06/15 22:04

我觉得很郁闷,写好之后保存发表显示

所以我一步一步的保存,看看是哪里被禁用了。

第一步下载:
网址dev.mysql.com/downloads/mysql/
选择Linux-Generic
下面会有很多下载安装包,我们选择最下面的Linux - Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive,如果你的系统是32位,就选择Linux - Generic (glibc 2.5) (x86, 32-bit), Compressed TAR Archive


第二步解压到指定目录
例如我的下载包在/home/下载/mysql-5.6.19-linux-glibc2.5-x86_64.tar.gz,我要把它安装到/opt/mysql5.6下,那么我要执行的命令如下
sudo cd /home/下载
sudo tar -zxvf mysql-5.6.19-linux-glibc2.5-x86_64.tar/gz
sudo mv mysql-5.6.19-linux-glibc2.5-x86_64 /opt/mysql5.6


第三步创建用户组和用户
这一步主要是为了安全起见,执行命令
sudo groupadd mysql,可能会提示使用apt-get install [指定的安装包],这时按提示执行命令sudo apt-get install mysql5.6,yes or no的时候选择y就好。
然后我们就可以创建用户和组了,各命令的意思在上一篇已经介绍了。
sudo groupadd mysql
sudo useradd -r -g mysql mysql

第四步更改权限(注意mysql后面有一个空格,再跟一个.)

sudo cd  /opt/mysql5.6

sudo chown -R mysql .

sudo chgrp -R mysql .


第五步初始化mysql授权表

sudo script/mysql_install_db --user=mysql


第五步修改配置文件my.cnf

sudo geidt my.cnf

我修改之后的配置文件如下:

# For advice on how to change settings please see

就是这个配置文件里面的一个地址我用图片来代替


[mysqld]


# 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 = /opt/mysql5.6

  datadir = /opt/mysql5.6/data

  port = 3306

# 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 optimahttps://note.wiz.cn/web?cmd=ca%2C%2FMy%20Notes%2Fubuntu%2F%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA%2F&dc=495ac518-4ad9-5c09-91dc-82447b1dbe8f&kb=c3f3e7c3-7b4b-4b00-a45c-0a3edad016fel values.

  join_buffer_size = 128M

  sort_buffer_size = 2M

  read_rnd_buffer_size = 2M 


sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES



第七步直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码,下面是我使用其登录的结果。
licheng@licheng-Aspire-4752:~$ mysql -udebian-sys-maint -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.6.17-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, 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> 

第八步连接数据库
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

第九步修改密码
mysql> update user set password='licheng888' where user='root';
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4  Changed: 4  Warnings: 0

第十步退出并使用新用户名和密码登录
mysql> exit
Bye
licheng@licheng-Aspire-4752:~$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.6.17-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2014, 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>
到此为止,大功告成。


0 0
原创粉丝点击