Home >Database >Mysql Tutorial >Linux非root用户安装MySQL

Linux非root用户安装MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:17:201970browse

Linux非root用户安装MySQL,首先wget mysql的安装包mysql-5.1.28-rc.tar.gz,5.1版本以前用configure进行编译,5.1之后的版本用cm

1. 首先wget mysql的安装包mysql-5.1.28-rc.tar.gz,,5.1版本以前用configure进行编译,5.1之后的版本用cmake进行编译。

把mysql-5.1.28-rc.tar.gz解压缩

tar -axvf mysql-5.1.28-rc.tar.gz

2. 进入解压缩后的文件夹 cd mysql-5.1.28-rc

3. 编译 $./configure --prefix=/*要安装的目录/mysql --with-charset=utf8 --with-plugins=innobase

例:$./configure --prefix=$HOME/mysql  --with-charset=utf8 --with-plugins=innobase

**=================================================**

编译Mysql时configure: error: No curses/termcap library found 的错误解决方法

说明 curses/termcap 库没有安装

root安装ncurses(或者编译安装ncurses,然后./configure编译的时候--with指定lib路径)

**=================================================**

4. $ make

$ make install

5. 拷贝一份配置文件到mysql的安装目录下并且重命名为my.cnf

在安装目录下share/mysql/ 下找到my-medium.cnf,,将它拷贝到安装目录并且重命名为my.cnf

6. 修改my.cnf文件

Socket = /***要安装的目录/mysql/mysql.sock (默认是在 /tmp/mysql.sock 因为我们是普通用户不能够操作/tmp/,mysql.sock这个文件在启动mysql时会自动生成,注意启动时的日志信息,如果报错,查看mysql安装目录下面的var目录里面的报错日志,可发现原因)

basedir=/安装的路径/mysql

datadir=/安装的路径/mysql/var

7. 初始化数据库表

安装目录/bin/mysql_install_db --user=mysql --datadir=/安装路径/mysql/var

例:$./mysql/bin/mysql_install_db --user=mysql --datadir=$HOME/mysql/var

8. 启动mysql服务

/安装路径/bin/mysqld_safe --defaults-file=/安装路径/my.cnf

例:$./mysql/bin/mysqld_safe --defaults-file=$HOME/mysql/my.cnf

9. 进入mysql数据库

/安装路径/bin/mysql -S /安装路径/mysql.sock

例:$./mysql/bin/mysql -S $HOME/mysql/mysql.sock 或者

./mysql/bin/mysql -h '127.0.0.1' -u root -p

10.修改root用户密码

$./mysql/bin/mysqladmin -h '127.0.0.1' -u root password 123

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn