欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Linux(Ubuntu)下Mysql5.6.28安装配置方法图文教程

程序员文章站 2023-12-11 23:29:40
mysql5.6.28安装配置方法 1.系统基本信息查看,尝试yum安装 $ sudo -s # df -lh filesystem size used...

mysql5.6.28安装配置方法

1.系统基本信息查看,尝试yum安装

$ sudo -s
# df -lh
filesystem  size used avail use% mounted on
/dev/vda1  79g 1.6g 74g 3% /
udev   3.9g 8.0k 3.9g 1% /dev
tmpfs   799m 252k 799m 1% /run
none   5.0m  0 5.0m 0% /run/lock
none   3.9g  0 3.9g 0% /run/shm
# uname -a
linux nj01 3.16.0-34-generic #47~14.04.1-ubuntu smp fri apr 10 17:49:16 utc 2015 x86_64 x86_64 x86_64 gnu/linux

# rpm -qa|grep yum
the program 'rpm' is currently not installed. you can install it by typing:
apt-get install rpm
# apt-get install rpm
……
# rpm -qa|grep yum
# yum install 
the program 'yum' is currently not installed. you can install it by typing:
apt-get install yum
# apt-get install yum
……
# yum install mysql
setting up install process
no package mysql available.
nothing to do

2.更换安装方式

# apt-get install mysql-server
reading package lists... done
building dependency tree      
reading state information... done
the following extra packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5
  mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5
suggested packages:
  libipc-sharedcache-perl tinyca mailx
the following new packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18 libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5
  mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5
0 upgraded, 13 newly installed, 0 to remove and 15 not upgraded.
need to get 27.6 mb of archives.
after this operation, 98.2 mb of additional disk space will be used.
do you want to continue [y/n]? y
get:1 http://apt.wmcloud.com/ubuntu/ precise-updates/main mysql-common all 5.5.52-0ubuntu0.12.04.1 [12.6 kb]
get:2 http://apt.wmcloud.com/ubuntu/ precise-updates/main libmysqlclient18 amd64 5.5.52-0ubuntu0.12.04.1 [952 kb]
get:3 http://apt.wmcloud.com/ubuntu/ precise/main libnet-daemon-perl all 0.48-1 [43.1 kb]
get:4 http://apt.wmcloud.com/ubuntu/ precise/main libplrpc-perl all 0.2020-2 [36.0 kb]
get:5 http://apt.wmcloud.com/ubuntu/ precise/main libdbi-perl amd64 1.616-1build2 [849 kb]
get:6 http://apt.wmcloud.com/ubuntu/ precise/main libdbd-mysql-perl amd64 4.020-1build2 [106 kb]
get:7 http://apt.wmcloud.com/ubuntu/ precise-updates/main mysql-client-core-5.5 amd64 5.5.52-0ubuntu0.12.04.1 [1,948 kb]
get:8 http://apt.wmcloud.com/ubuntu/ precise/main libterm-readkey-perl amd64 2.30-4build3 [28.6 kb]
get:9 http://apt.wmcloud.com/ubuntu/ precise-updates/main mysql-client-5.5 amd64 5.5.52-0ubuntu0.12.04.1 [8,365 kb]
get:10 http://apt.wmcloud.com/ubuntu/ precise-updates/main mysql-server-core-5.5 amd64 5.5.52-0ubuntu0.12.04.1 [6,327 kb]
get:11 http://apt.wmcloud.com/ubuntu/ precise-updates/main mysql-server-5.5 amd64 5.5.52-0ubuntu0.12.04.1 [8,855 kb]
get:12 http://apt.wmcloud.com/ubuntu/ precise/main libhtml-template-perl all 2.10-1 [65.0 kb]
get:13 http://apt.wmcloud.com/ubuntu/ precise-updates/main mysql-server all 5.5.52-0ubuntu0.12.04.1 [10.8 kb]
fetched 27.6 mb in 0s (38.2 mb/s)   
preconfiguring packages ...
selecting previously unselected package mysql-common.
(reading database ... 77501 files and directories currently installed.)
unpacking mysql-common (from .../mysql-common_5.5.52-0ubuntu0.12.04.1_all.deb) ...
selecting previously unselected package libmysqlclient18.
unpacking libmysqlclient18 (from .../libmysqlclient18_5.5.52-0ubuntu0.12.04.1_amd64.deb) ...
selecting previously unselected package libnet-daemon-perl.
unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.48-1_all.deb) ...
selecting previously unselected package libplrpc-perl.
unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
selecting previously unselected package libdbi-perl.
unpacking libdbi-perl (from .../libdbi-perl_1.616-1build2_amd64.deb) ...
selecting previously unselected package libdbd-mysql-perl.
unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.020-1build2_amd64.deb) ...
selecting previously unselected package mysql-client-core-5.5.
unpacking mysql-client-core-5.5 (from .../mysql-client-core-5.5_5.5.52-0ubuntu0.12.04.1_amd64.deb) ...
selecting previously unselected package libterm-readkey-perl.
unpacking libterm-readkey-perl (from .../libterm-readkey-perl_2.30-4build3_amd64.deb) ...
selecting previously unselected package mysql-client-5.5.
unpacking mysql-client-5.5 (from .../mysql-client-5.5_5.5.52-0ubuntu0.12.04.1_amd64.deb) ...
selecting previously unselected package mysql-server-core-5.5.
unpacking mysql-server-core-5.5 (from .../mysql-server-core-5.5_5.5.52-0ubuntu0.12.04.1_amd64.deb) ...
processing triggers for man-db ...
setting up mysql-common (5.5.52-0ubuntu0.12.04.1) ...
selecting previously unselected package mysql-server-5.5.
(reading database ... 77879 files and directories currently installed.)
unpacking mysql-server-5.5 (from .../mysql-server-5.5_5.5.52-0ubuntu0.12.04.1_amd64.deb) ...
selecting previously unselected package libhtml-template-perl.
unpacking libhtml-template-perl (from .../libhtml-template-perl_2.10-1_all.deb) ...
selecting previously unselected package mysql-server.
unpacking mysql-server (from .../mysql-server_5.5.52-0ubuntu0.12.04.1_all.deb) ...
processing triggers for ureadahead ...
processing triggers for man-db ...
setting up libmysqlclient18 (5.5.52-0ubuntu0.12.04.1) ...
setting up libnet-daemon-perl (0.48-1) ...
setting up libplrpc-perl (0.2020-2) ...
setting up libdbi-perl (1.616-1build2) ...
setting up libdbd-mysql-perl (4.020-1build2) ...
setting up mysql-client-core-5.5 (5.5.52-0ubuntu0.12.04.1) ...
setting up libterm-readkey-perl (2.30-4build3) ...
setting up mysql-client-5.5 (5.5.52-0ubuntu0.12.04.1) ...
setting up mysql-server-core-5.5 (5.5.52-0ubuntu0.12.04.1) ...
setting up mysql-server-5.5 (5.5.52-0ubuntu0.12.04.1) ...
160928 10:56:48 [warning] using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. please use the full name instead.
160928 10:56:48 [note] /usr/sbin/mysqld (mysqld 5.5.52-0ubuntu0.12.04.1) starting as process 6166 ...
mysql start/running, process 6304
setting up libhtml-template-perl (2.10-1) ...
setting up mysql-server (5.5.52-0ubuntu0.12.04.1) ...
processing triggers for libc-bin ...
ldconfig deferred processing now taking place

安装过程中输入root的密码即可;

3.安装成功,基本配置

mysql> grant all privileges on *.* to 'root'@'%' identified by '******';
query ok, 0 rows affected (0.00 sec)

mysql> 
mysql> 
mysql> 
mysql> 
mysql> 
mysql> create database testdb;
query ok, 1 row affected (0.01 sec)

mysql> 
mysql> 
mysql> 
mysql> 
mysql> show databases;
+--------------------+
| database   |
+--------------------+
| information_schema |
| mysql    |
| testdb    |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

mysql> insert into mysql.user(host,user,password) values("%","test",password("******"));
query ok, 1 row affected, 3 warnings (0.00 sec)

mysql> 
mysql> flush privileges;
query ok, 0 rows affected (0.00 sec)

mysql> grant all privileges on testdb.* to 'test'@'% identified by '******';
query ok, 0 rows affected (0.00 sec)

mysql> flush privileges;
query ok, 0 rows affected (0.00 sec)

4.问题解决

(1)访问报错,网络连接报错:10038 ,telnet 不通
s1.关闭防火墙 # ufw allow 3306 ,还是不行
s2.用户网络权限已经给了(rant all privileges on . to ‘root'@'%' identified by ‘youpassword' with grant option;)
s3.查看网路信息 # netstat -ano
tcp 0 0 127.0.0.1:3306
应该是绑定ip问题,修改/etc/mysql/my.conf
找到bind-address = 127.0.0.1这一行
改为bind-address = 0.0.0.0,问题解决。
(2)表区分大小写:
用root帐号登录后,在/etc/my.cnf 中的[mysqld]后添加添加lower_case_table_names=1,重启mysql服务,这时已设置成功:不区分表名的大小写;
lower_case_table_names参数详解:
lower_case_table_names = 0
其中 0:区分大小写,1:不区分大小写

5.基本服务命令

# 启动mysql$ sudo service mysql start 
# 关闭mysql$ sudo service mysql stop
# 重启mysql$ sudo service mysql restart
# 其他命令:$ sudo /etc/init.d/mysql start
$ sudo /etc/init.d/mysql stop
$ sudo /etc/init.d/mysql restart

6.卸载mysql:

sudo apt-get autoremove mysql* --purge
sudo apt-get remove apparmor
sudo apt-get install mysql-server mysql-common

卸载后删除mysql相关文件(/var/lib/mysql , /etc/mysql等等,可以用 find -name mysql 查询下相关路径)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

上一篇:

下一篇: