搭建mysql数据库
#安装编译工具与插件
yum -y install \
gcc \
gcc-c++ \
make \
ncurses \
ncurses-devel \
bison \
cmake
#建立数据库程序用户
useradd -s /sbin/nologin MySQL
yum install lrz* -y
成都创新互联公司10多年企业网站建设服务;为您提供网站建设,网站制作,网页设计及高端网站定制服务,企业网站建设及推广,对成都阳光房等多个领域拥有多年设计经验的网站建设公司。
#解压mysql安装包
tar xf mysql-boost-5.7.20.tar.gz -C /opt/
cd /opt/mysql-5.7.20/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/etc \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1
#编译与安装
make && make install
#对数据库目录进行权限配置
chown -R mysql.mysql /usr/local/mysql/
vi /etc/my.cnf
删除里面所有内容并把以下内容添加到里面
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock
[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
:wq //保存退出
chown mysql:mysql /etc/my.cnf //配置文件属主与属组
#设置环境变量
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
//把这两个路径添加到环境变量中,并放到profile文件中使之开机自运行,否则不生效
echo 'export PATH' >> /etc/profile //设为全局变量,使它使用环境更广
source /etc/profile //立即生效
#初始化数据库
cd
cd /usr/local/mysql/
bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
cp usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl start mysqld
netstat -anpt | grep 3306 //查看服务运行状态
systemctl enable mysqld //设为开机启动
#访问数据库操作
mysqladmin -u root -p password "abc123" //给root账号设置密码
mysql -uroot -pabc123 //登录数据库
有密码的加“-p”,如果没有密码不用加“-p”
数据库安装配置成功,退出则输入”quit“
网页题目:搭建mysql数据库
标题路径:http://myzitong.com/article/pcidhp.html