ubuntu离线安装mysql_ubuntu 离线包安装mysql

本文提供了一种在Ubuntu上离线安装MySQL 5.6的方法,包括禁用AppArmor、创建mysql用户组和用户、安装依赖、解压MySQL离线包、处理启动时的错误、设置权限、启动MySQL服务、设置root密码以及允许远程访问的步骤。此外,还提到了安装后的目录结构和常用的MySQL图形化管理软件。
摘要由CSDN通过智能技术生成

1 Preliminary Note

Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typingsudo su

2 Disabling AppArmor

Your manually installed MySQL 5.6.8 might refuse to start if AppArmor is running, therefore we disable AppArmor:/etc/init.d/apparmor stop

update-rc.d -f apparmor remove

apt-get remove apparmor apparmor-utils

3 Installing MySQL 5.6.8rc1 (Linux Generic)

First we create a user and group called mysql:groupadd mysql

useradd -r -g mysql mysql

Next install the libaio1 package:apt-get install libaio1

Next:下载和安装

下载:可以在Oracle 官网下载离线包:我下载的为mysql-5.6.12-linux-glibc2.5-i686.tar.gz

将离线包复制到 /usr/local下

Unpack MySQL, rename the directory to mysql, and make it owned by the user and group mysql:tar xvfz mysql-5.6.12-linux-glibc2.5-i686.tar.gz

mv mysql-5.6.12-linux-glibc2.5-i686 mysql

cd mysql

chown -R mysql .

chgrp -R mysql .

Runscripts/mysql_install_db --user=mysql

在这里可能会出现错误:

Installing MySQL system tables..../bin/mysqld: error whileloading shared libraries: libaio.so.1: cannot open shared objectfile: No such file or directory

解决办法:

这说明还要安装一个libaio的依赖库:

sudo apt-get install libaio-dev

然后重新执行:scripts/mysql_install_db --user=mysql

to create the necessary databases (like the mysql database):

Change some ownerships:chown -R root .

chown -R mysql data

MySQL uses the my.cnf file inside /usr/local/mysql, so we don't have to create one on our own. If you want to change MySQL settings, you can do it in that file.

The downloaded MySQL package comes with the init script mysql.server which we copy to /etc/init.d as follows:cp support-files/mysql.server /etc/init.d/mysql.server

It is already executable, so we don't have to change permissions.

We can now start MySQL 5.6 as follows:/etc/init.d/mysql.server start

To make MySQL start automatically at boot time, run the following command:update-rc.d mysql.server defaults

The MySQL commands (like mysql, mysql_secure_installation, etc.) are located in the /usr/local/mysql/bin directory which is not in the PATH which means we would have to call these commands with the full or relative path which is cumbersome. To avoid this, we create the following symlink so that we can call all MySQL commands without a path:

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

Finally, we should set a MySQL root password:

mysql_secure_installation

root@server1:/usr/local/mysql# mysql_secure_installation

启动MySQL服务:                       sudo start mysql

停止MySQL服务:                       sudo stop mysql

修改 MySQL 的管理员密码:     sudo mysqladmin -u root password newpassword

设置远程访问(正常情况下,mysql占用的3306端口只是在IP 127.0.0.1上监听,拒绝了其他IP的访问(通过netstat可以查看到)。取消本地监

听需要修改 my.cnf 文件:):

sudo vi /etc/mysql/my.cnf

bind-address = 127.0.0.1 //找到此内容并且注释

4)MySQL安装后的目录结构分析(此结构只针对于使用apt-get install 在线安装情况):

数据库存放目录:              /var/lib/mysql/

相关配置文件存放目录:          /usr/share/mysql

相关命令存放目录:             /usr/bin(mysqladmin mysqldump等命令)

启动脚步存放目录:            /etc/rc.d/init.d/

5)MySQL图形化管理软件

一般使用的有两个比较好,一个开源,一个商业收费:

开源:MySQL Workbench   (具体使用介绍随着我的使用,我会慢慢总结)

商业:Navicat (收费的,有30天体验,之后我相信大家会有办法的)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值