飞腾、龙芯、源码编译mysql数据库
公司不能连接外⽹,要安装mysql数据库只能安装包安装,⽬前公司在龙芯服务器上安装,也就是mips64el架构上安装,mysql在此不适配,所以要源码编译安装mysql。
在此⽤编译mysql,n多次,⼏天的时间过去了,⼀直报错,报错解决再报错,再解决,实在不⾏。需要修改源码⾥⾯的东西,后来了解到mips64el,不⽀持mysql,在龙芯上只能⽤mariadb。其实都是⼀样,但龙芯上就是不⽀持,没办法。重新换为mariadb来编译,也是尝试了n多次,终于成功了。在此将详细过程展⽰如下:
安装⼀些依赖包 gcc、g++、bison、make、cmake、libncurses5-dev
预编译:
cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
# 注:
#第⼀⾏是mysql主程序安装⽬录
#第⼆⾏是配置⽂件⽬录
#第三⾏默认字符集为utf8
#第四⾏默认的字符集效对规则
#第五⾏安装所有字符集
编译安装:
make && make install
安装完成之后:make clean  清除编译过程中产⽣的临时⽂件和配置过程中产⽣的⽂件    ⾄此,软件安装完成
创建mysql⽤户:
groupadd mysql
[ root@localhost / ]# useradd -M -s /sbin/nologin -g mysql mysql
MariaDB配置⽂件创建及更改。
[ root@localhost / ]# cp support-files/my-mediumf /etc/myf
#复制配置⽂件
[ root@localhost / ]# cp support-files/mysql.server  /etc/init.d/mysqld  将它放在init.d中以让其⾃动启动
#复制启动脚本
[ root@localhost / ]# vim /etc/myf
basedir=/usr/local/mysql
datadir = /usr/local/mysql/data/
#指定数据库路径,不然⽆法启动mysql
innodb_file_per_table = on
#设置后当创建数据库的表的时候表⽂件都会分离开,⽅便复制表,不开启创建的表都在⼀个⽂件
skip_name_resolve = on
#跳过名称反解,Mysql每次使⽤客户端链接时都会把ip地址反解成主机名
执⾏开机⾃动启动系统服务:update-rc.d mysqld defaults            卸载脚本的⽅法(需进⼊init.d中):update-rc.d -f XXX remove
⽤法:⾸先确保脚本已在/etc/init.d⽬录下,然后⽤:
update-rc.d XXX defaults NN 命令(NN为启动顺序),将
脚本添加到初始化执⾏的队列中去。按照⾃⼰的需要启动脚本的顺序来指定相应的修改
注意:如果脚本需要⽤到⽹络,则NN需要设置⼀个⽐较⼤的数字,如99
设置开机⾃启动的⽅法:chkconfig --add test
重启后永久⽣效:chkconfig test on/off
安装数据库系统表:
./mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
启动mysql数据: /usr/local/mysql/bin/mysqld_safe &
安全初始化mysql及设定:  /usr/local/mysql/bin/mysql_secure_installation
执⾏步骤:
/usr/local/mysql/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):    #回车
OK, successfully used password,
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y  #是否设置root密码
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n]    #删除匿名账号
... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n]  #是否禁⽌root账号远程登录,⽣产环境中⼀定要禁⽌
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y    #是否清除测试数据库
- Dropping
... Success!
- Removing privileges on
... Success!
Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
Reload privilege tables now? [Y/n] y  #重载
... Success!
All done!  If you've completed all of the above steps, your MariaDB installation should now be secure.
Thanks for using MariaDB!
测试能否登录⼊数据库
root@9d3ce8f77312:/usr/local/mysql/bin# mysql -u root -p111111 Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.60-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database          |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]>
开机即启动mysql 以及添加到全局变量需要每次更新
在/etc/.bashrc⾥⾯添加
source /etc/profile
mysql服务器安装教程
/etc/init.d/mysqld start
达到开机即启动

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。