安装mysql

mysql下载https://downloads.mysql.com/archives/community/
安装文档https://dev.mysql.com/doc/refman/5.7/en/installing-source-distribution.html

安装时指定了DWITH_SSL使用了openssl3.1.0安装后需要解压执行make install,发现最后执行 bin/mysql_ssl_rsa_setup提示openssl未安装,openssl3.1.0安装后要执行【ldconfig /usr/local/lib64/】否则不生效,升不生效要执行openssl看看正常否

遇到问题:
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
yum install gcc-c++

CMake Error at cmake/boost.cmake:88 (MESSAGE): You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
下载https://www.boost.org/
Boost minor version found is 74 we need 59
下载对应的_59版本,可以通过cmake时自动安装;如果因为ssl证书下载不到就需要手动下载并解压-DWITH_BOOST指定解压后的目录即可不用安装

#安照cmake ..报错时提示的
cmake ..  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost_1_59

安装时提示openssl问题时如果是自定义安装的可以指定

cmake ..  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost_1_59_0 -DWITH_SSL=/usr/local/openssl

提示CMake Error at cmake/ssl.cmake:247 (MESSAGE):SSL version must be at least 1.1.1;去官网https://www.openssl.org/source/会看到两个版本

 

 mysql中使用的是/usr/bin下的openssl操作后会进入openssl>模式而3.0不会,提示openssl版本过时时应该下载openssl-1.1.1n这个版本

Make Error at cmake/ssl.cmake:63 (MESSAGE): Please install the appropriate openssl developer package
yum -y install openssl-devel
rm -f CMakeCache.txt

CMake Error at cmake/readline.cmake:71 (MESSAGE): Curses library not found. Please install appropriate package
yum install ncurses-devel.x86_64

# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> mkdir bld
shell> cd bld
shell> cmake ..
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
A temporary password is generated for root@localhost: M_ORdyr4uL+O
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

安装后需要创建/etc/my.cnf的文件的目录如/var/run和/var/log关于编译源码安装的mysql如何重启的问题,参考在安装目录下找到support-files里边的mysql.server命令即可进行重启;

Usage: mysql.server  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]

/usr/local/mysql/support-files/mysql.server restart --user=root 重启时遇到问题

 

 这里找不到pid,要将[mysqld_safe]中的pid-file配置复制到[mysqld]中一份即可

重置root密码;可以尝试使用mysqladmin工具
pkill mysql
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables
新开终端/usr/local/mysql/bin/mysql -u root
连接时报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock

[client]
port=3306
socket=/var/lib/mysql/mysql.sock#需要跟mysqld的socket路径一样

mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('');#mysql-8修改不需要加password(),直接明文如="123456"
mysql>/usr/local/mysql/bin/mysqld_safe --user=mysql &

wamp添加新版mysql8,添加之后启动不了查看错误wamp下的mysql错误日志提示,一开始是没有data目录,手动添加data目录时报错:Failed to find valid data directory. [ERROR] [MY-010020] [Server] Data Dictionary initialization failed,通过搜索发现需要使用mysqld自带的初始化自动生成的data目录才能使用,先手动删除data目录之后使用命令mysqld --initialize-insecure,完成data目录初始化后,mysqld --install ,安装mysqld服务,然后可以正常启动服务了

 某天重启了linux服务器发现使用mysqld_safe启动不了了,查看日志需要根据/etc/my.cnf中配置在/var/run下新建myql目录,因为/var/run是tmpfs文件系统是基于内容的,每次重启服务后就消失了需要重新建立

mysql安装后设置新密码后过段时间登陆不上是因为password expiry机制存在可通过以下方式解决

SET GLOBAL default_password_lifetime = 0;或my.cnf中[mysqld] default_password_lifetime = 0;

ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword','root'@'localhost' PASSWORD EXPIRE NEVER;

 通过root用户创建完数据库一直提示:(HY000): Can't read dir of './bg/' (errno: 13 - Permission denied)查看/var/lib/mysql/目录中bg库为root没有权限访问,通过修改chown -R mysql:mysql bg

 

posted @ 2014-09-20 21:38  大匠  Views(466)  Comments(0Edit  收藏  举报