Linux ARM机器,源码安装mysql5.7.23,并且运行

背景:华为云  系统版本:EulerOS release 2.0 (SP8)

 

第一节:源码安装mysql5.7.23


一、下载

yum install ncurses-devel -y
yum install rpcgen -y
wget https://downloads.mysql.com/archives/get/file/mysql-boost-5.7.23.tar.gz
tar zxvf mysql-boost-5.7.23.tar.gz
cd mysql-5.7.23/

二、编译

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/mysql-5.7.23/boost

注意:最后面指定的BOOST路径应该修改为mysql-5.7.23/boost的绝对路径。

如果没有出现错误,就是正常的 make && make install

 

三、遇到的错误

错误提示1:Curses library not found
解决方案:

rm -rf CMakeCache.txt
yum install ncurses-devel

从第二步重试(重新cmake)

错误提示2:Could not find rpcgen

解决方案:

rm -rf CMakeCache.txt
yum install rpcgen

从第二步重试(重新cmake)

错误提示3:Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc

-- Running cmake version 3.12.1
-- Configuring with MAX_INDEXES = 64U
-- CMAKE_GENERATOR: Unix Makefiles
-- SIZEOF_VOIDP 8
-- MySQL 5.7.23
-- Packaging as: mysql-5.7.23-Linux-aarch64
-- Local boost dir /home/geostar/geoglobe/mysql/mysql-5.7.23/boost/boost_1_59_0
-- Found /home/geostar/geoglobe/mysql/mysql-5.7.23/boost/boost_1_59_0/boost/version.hpp 
-- BOOST_VERSION_NUMBER is #define BOOST_VERSION 105900
-- BOOST_INCLUDE_DIR /home/geostar/geoglobe/mysql/mysql-5.7.23/boost/boost_1_59_0
-- NUMA library missing or required version not available
-- WITH_PROTOBUF=bundled
-- protobuf version is 2.6
-- You need to set WITH_CURL. This variable needs to point to curl library.
-- Creating LDAP authentication SASL client library.
-- Required SASL library is missing. Skipping the LDAP SASL client authentication plugin.
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;atomic;dl
-- MERGE_CONVENIENCE_LIBRARIES TARGET mysqlclient
-- MERGE_CONVENIENCE_LIBRARIES LIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib;yassl;taocrypt;dl
-- MERGE_CONVENIENCE_LIBRARIES MYLIBS clientlib;dbug;strings;vio;mysys;mysys_ssl;zlib;yassl;taocrypt
CMake Error at rapid/plugin/group_replication/rpcgen.cmake:97 (MESSAGE):
  Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc
Call Stack (most recent call first):
  rapid/plugin/group_replication/CMakeLists.txt:29 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/home/geostar/geoglobe/mysql/mysql-5.7.23/CMakeFiles/CMakeOutput.log".
See also "/home/geostar/geoglobe/mysql/mysql-5.7.23/CMakeFiles/CMakeError.log".

解决方案:

复制其他机器上面的rpc文件夹到这个文件夹中。

scp /usr/include/rpc/*.h [email protected]:/usr/include/rpc/.

上面只是示范,192.168.1.1是目标机器。上面的命令在原机器上执行

第二节:运行mysql


一、设置权限,添加mysql组和用户

使用下面的命令查看是否有mysql用户及用户组:
cat /etc/passwd     //查看用户列表
cat /etc/group      //查看用户组列表

如果没有就创建:
groupadd mysql   //创建mysql组
useradd -g mysql mysql   //创建属于mysql组的mysql用户
passwd mysql  //为mysql用户创建登录密码

修改/usr/local/mysql权限:chown -R mysql:mysql /usr/local/mysql

二、加入环境变量

echo $PATH

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

三、mysqld初始化

/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --explicit_defaults_for_timestamp=true

2019-08-20T09:11:10.268167Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-08-20T09:11:10.442029Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-08-20T09:11:10.702832Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 739a0904-c32a-11e9-8108-fa163e8a366b.
2019-08-20T09:11:10.706663Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-08-20T09:11:10.707259Z 1 [Note] A temporary password is generated for root@localhost: 9cC5ycy(phS,

初始化成功后,上面结果会在控制台打印临时管理员密码,如:...root@localhost: 9cC5ycy(phS,其中9cC5ycy(phS就是密码。

说明:上面语句执行时容易报错,成功至少要满足以下几个条件
① /usr/local/mysql/data目录存在并且一定要为空目录,否则报错;
实例对应的datadir目录中,再启动此实例,然后重新执行初始化命令;

四、mysql服务启动

cd /usr/local/mysql/support-files
./mysql.server start

五、mysql安全模式修改root密码

如果使用上面的密码无论如何都登陆不进去,那么采用安全模式更改密码

cd /usr/local/mysql/bin
./mysqld_safe --skip-grant-tables

use mysql  
update user set password=password("你想要的密码") where user="root";
flush privileges;

然后终端输入mysql -uroot -p

使用mysql的后台命令。

注意,进入安全模式的时候需要没有mysql任何相关的进程,如果报错那就杀掉所有mysql相关的进程。

ps -aux | grep mysql | grep -v grep

kill -9 ***

六、mysql修改root密码

mysql> use mysql;
Database changed
mysql> select User from user;  #此处为查询用户命令
+-----------+
| User      |
+-----------+
| *******  |
| mysql.sys |
| root      |
+-----------+
3 rows in set (0.00 sec)

mysql> update user set password=password("*******") where user="*******";  #修改密码报错
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
mysql> update mysql.user set authentication_string=password('*******') where user='*******';  #修改密码成功
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;  #立即生效
Query OK, 0 rows affected (0.00 sec)

如果一直有问题,重复上面几个步骤

七、root用户,外网访问

mysql命令行

use mysql;

update user set host='%' where user = 'root';

flush privileges;

八、创建用户,并且赋予用户所有权限

进入mysql命令行后,

create user 'username'@'host' identified by 'password';

host 改为 % 意思是可以外网访问

grant all privileges on *.* to 'username'@'%' identified by 'password';
flush privileges;

你可能感兴趣的:(linux)