龙空技术网

Ubuntu手动安装MySQL

碎冰冰的萝卜坑 143

前言:

当前你们对“ubuntu清理mysql”都比较关怀,咱们都需要剖析一些“ubuntu清理mysql”的相关内容。那么小编同时在网摘上收集了一些关于“ubuntu清理mysql””的相关文章,希望看官们能喜欢,姐妹们一起来了解一下吧!

从官网下载安装包MySQL :: Download MySQL Community Server

解压到/usr/local目录下,重命名为mysql

然后在终端输入以下命令:

shell> groupadd mysql

shell> useradd -r -g mysql mysql

shell> cd /usr/local

shell> cd mysql

shell> chown -R mysql . (别忘了最后有一个点,下同)

shell> chgrp -R mysql .

shell> scripts/mysql_install_db --user=mysql

这句执行后如果报错:

scripts/mysql_install_db: 244: ./bin/my_print_defaults: not found

Neither host 'ubuntu' nor 'localhost' could be looked up with

./bin/resolveip

Please configure the 'hostname' command to return a correct

hostname.

If you want to solve this at a later stage, restart this script

with the --force option

在终端输入uname -a命令查看系统版本,如果结果为x86_64则说明系统是64位的,是不是下载的安装包不对了?到官网下载64位版本的,把刚解压到mysql目录删掉,重新执行上面这一条语句

如果又报错:./bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

这说明少个东西,执行下面这条命令:

sudo apt-get install libaio-dev

安装完成后再执行scripts/mysql_install_db --user=mysql这条语句

继续执行后续命令:

shell> chown -R root .

shell> chown -R mysql data

好了,下面启动:

sudo ./support-files/mysql.server start

# /usr/local/mysql/bin/mysqld_safe --user=mysql &

cd /usr/local/mysql/bin //进入 bin目录

#mysql //运行mysq命令

如果没有没有启动 或出现 Can't connect to local MySQL server through socket '/tmp/mysql.sock'

解决方法: #cd /usr/local/mysql/support-files //进入该目录

#./mysql.server start //启动即可 既可在生成/tmp/mysql.sock

如果/tmp/mysql.sock 无该文件存在,且mysql是处于开启的状态?

解决方法: #netstat -an | grep 3306 //查看 3306端口

#ps -ef | grep mysql // 查找 mysql 进程

# kill -9 进程号 //强制删除mysql的进程号

#./mysql.server start //启动即可 既可在生成/tmp/mysql.sock

如果在任意路径下如数mysql命令得到的无该命令咋办呢?

解决方法:修改 /etc/profile 文件 在文件中加入

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

export PATH (保存即可退出执行 source /etc/profile)

以上操作完全可以 在任意目录执行# mysql 命令

如果想执行 service mysql start or restart stop 命令咋办的? 在不能老#./mysql.server start

解决方法:将 mysql.server 复制一份到 /etc/rc.d/init.d 下并改名 mysql 或 建个连接文件

假设当前目录为 /etc/rc.d/init.d

如: #cp /usr/local/mysql/support-files/mysql.server mysql (复制)

或 : #ln -s /usr/local/mysql/support-files/mysql.server mysql (建立连接文件)

完成以上操作即可 执行 service mysql start (or restart stop)

用如下命令修改MYSQL密码

# /usr/local/mysql/bin/mysqladmin -u root password yourpassword //默认安装密码为空,为了安全你必须马上修改

# chmod 700 /etc/init.d/mysql

# chkconfig --add mysqld

# chkconfig --level 345 mysql on //copy编译目录的一个脚本设置使mysql每次启动都能自动运行

# service mysql start

# netstat -atln

//启动mysql服务

//查看3306端口是否打开。要注意在防火墙中开放该端口。

可以用telnet localhost 3306来测试一下,如果有反应,那就表明安装成功了

标签: #ubuntu清理mysql