非root安装mysql并设置远程访问
在linux下mysql 5.5.24安装 我是非root在linux下源码安装,由于已有几个mysql前4步省略:1、安装所需要系统库相关库文件2、创建mysql安装目录 # mkdir -p /usr/local/mysql/3、创建数据存放目录 # mkdir -p /service/mysql/4、创建用户和用户组与赋予数据存放目录
·
在linux下mysql 5.5.24安装
我是非root在linux下源码安装,由于已有几个mysql前4步省略:
1、安装所需要系统库相关库文件
2、创建mysql安装目录
# mkdir -p /usr/local/mysql/
3、创建数据存放目录
# mkdir -p /service/mysql/
4、创建用户和用户组与赋予数据存放目录权限
# groupadd mysql
# useradd -g mysql mysql
# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#./configure
# make && make install
6、下载解压mysql 5.5.15
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.15.tar.gz
[root@localhost down]# tar zxvf mysql-5.5.15.tar.gz
[root@localhost down]# cd mysql-5.5.15
7、编辑mysql
要搞清楚每个配置的含义,否则很容易出错!!!
/home/work/ss/local/bin/cmake .
-DCMAKE_INSTALL_PREFIX=/home/work/ss/mysql
-DMYSQL_DATADIR=/home/work/ss/mysql/data/
-DMYSQL_UNIX_ADDR=/home/work/ss/mysql/data/mysqld.sock
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DSYSCONFDIR=/home/work/ss/mysql
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_unicode_ci
-DMYSQL_TCP_PORT=8807
-DWITH_DEBUG=0
源代码配置选项说明:
//mysql安装的主目录,5.5.8版本默认为/usr/local/mysql,所以可以不添加
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
//mysql数据保存的路径,自定义
-DMYSQL_DATADIR=/home/system_username/mysql/mysqldata
//mysql配置文件地址------The default my.cnf option file directory
-DSYSCONFDIR=/etc
//Compile storage engine xxx statically into server
/*Storage engines are built as plugins. You can build a plugin as a static module (compiled into the server)
*or a dynamic module (built as a dynamic library that must be installed into the server using the INSTALL
*PLUGIN statement or the --plugin-load option before it can be used). Some plugins might not support static
*or dynamic building.
*/
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
//Unix socket file
/*
*The Unix socket file path on which the server listens for socket connections. This must be an absolute path
*name. The default is /tmp/mysql.sock
*/
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
//数据库服务器TCP/IP连接的监听端口,默认为3306
-DMYSQL_TCP_PORT=3306
//Whether to enable LOCAL capability in the client library for LOAD DATA INFILE
//默认为关闭,这里开启
-DENABLED_LOCAL_INFILE=1
//数据库编码设置
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8-general_ci
8、make && make install
9、安装数据库
scripts/mysql_install_db --user=mysql --basedir=/home/work/ss/mysql --datadir=/home/work/ss/mysql/data/
权限设置,先是设root密码,再是设远程连接!!!!
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql>mysql -u root mysql
mysql>update user set password=PASSWORD("root") where user='root';
mysql>FLUSH PRIVILEGES;
mysql>grant all on *.* to user_name@'%' identified by 'use_password';
mysql>FLUSH PRIVILEGES;
我是非root在linux下源码安装,由于已有几个mysql前4步省略:
1、安装所需要系统库相关库文件
2、创建mysql安装目录
# mkdir -p /usr/local/mysql/
3、创建数据存放目录
# mkdir -p /service/mysql/
4、创建用户和用户组与赋予数据存放目录权限
# groupadd mysql
# useradd -g mysql mysql
# chown mysql.mysql -R /service/mysql/
我是从下面开始进行的:
5、安装cmake(mysql5.5以后是通过cmake来编译的)# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#./configure
# make && make install
6、下载解压mysql 5.5.15
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.15.tar.gz
[root@localhost down]# tar zxvf mysql-5.5.15.tar.gz
[root@localhost down]# cd mysql-5.5.15
7、编辑mysql
要搞清楚每个配置的含义,否则很容易出错!!!
/home/work/ss/local/bin/cmake .
-DCMAKE_INSTALL_PREFIX=/home/work/ss/mysql
-DMYSQL_DATADIR=/home/work/ss/mysql/data/
-DMYSQL_UNIX_ADDR=/home/work/ss/mysql/data/mysqld.sock
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DSYSCONFDIR=/home/work/ss/mysql
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_unicode_ci
-DMYSQL_TCP_PORT=8807
-DWITH_DEBUG=0
源代码配置选项说明:
//mysql安装的主目录,5.5.8版本默认为/usr/local/mysql,所以可以不添加
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
//mysql数据保存的路径,自定义
-DMYSQL_DATADIR=/home/system_username/mysql/mysqldata
//mysql配置文件地址------The default my.cnf option file directory
-DSYSCONFDIR=/etc
//Compile storage engine xxx statically into server
/*Storage engines are built as plugins. You can build a plugin as a static module (compiled into the server)
*or a dynamic module (built as a dynamic library that must be installed into the server using the INSTALL
*PLUGIN statement or the --plugin-load option before it can be used). Some plugins might not support static
*or dynamic building.
*/
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
//Unix socket file
/*
*The Unix socket file path on which the server listens for socket connections. This must be an absolute path
*name. The default is /tmp/mysql.sock
*/
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
//数据库服务器TCP/IP连接的监听端口,默认为3306
-DMYSQL_TCP_PORT=3306
//Whether to enable LOCAL capability in the client library for LOAD DATA INFILE
//默认为关闭,这里开启
-DENABLED_LOCAL_INFILE=1
//数据库编码设置
-DEXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8-general_ci
8、make && make install
9、安装数据库
scripts/mysql_install_db --user=mysql --basedir=/home/work/ss/mysql --datadir=/home/work/ss/mysql/data/
权限设置,先是设root密码,再是设远程连接!!!!
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql>mysql -u root mysql
mysql>update user set password=PASSWORD("root") where user='root';
mysql>FLUSH PRIVILEGES;
mysql>grant all on *.* to user_name@'%' identified by 'use_password';
mysql>FLUSH PRIVILEGES;
mysql>quit;
windows下的前端用的Navicat进行管理,写sql语句太繁琐了,直接图形界面解决。
更多推荐
已为社区贡献5条内容
所有评论(0)