Manjaro安装mongodb和mysql踩坑记录

MongoDB环境安装

yay -S mongodb34-bin

这个时候运行mongo命令我出现以下报错

MongoDB shell version v3.4.16
connecting to: mongodb://127.0.0.1:27017
2019-12-06T11:47:58.912+0800 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2019-12-06T11:47:58.916+0800 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:240:13
@(connect):1:6
exception: connect failed

这里需要启动服务

systemctl start mongodb.service // 启动服务
system enable mongodb // 设置开机自启动

这样就可以了,还可以安装一个客户端

yay -S robo3t-bin  // 安装可视化界面

安装mysql

sudo pacman -S mysql
mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql // 初始化mysql

执行初始化的过程中我出现以下报错

mysqld: error while loading shared libraries: libicuuc.so.65: cannot open shared object file: No such file or directory

百度过后,参考这个大佬的解答:https://www.guqing.xyz/archives/mysql-libicu

以下我git clone时没有这个包,使用wget是可以下载的,速度不敢想像,这是百度网盘下载链接

链接: https://pan.baidu.com/s/1la6H_cepkyaNpFZIMz7-yg 提取码: nbt7 复制这段内容后打开百度网盘手机App,操作更方便哦。

当然,如果CSDN有vip的话,可以在我上传的资源中找到,下载即可。
下载到包以后从tar解压开始依次执行以下命令。

git clone https://github.com/unicode-org/icu/releases/download/release-65-rc/icu4c-65rc-src.tgz
tar -zxvf icu4c-65rc-src.tgz
cd icu/source
./configure
make
sudo make install
sudo ln -s /usr/local/lib/libicuuc.so.65 /usr/lib/libicuuc.so.65
sudo ln -s /usr/local/lib/libicui18n.so.65 /usr/lib/libicui18n.so.65
sudo ln -s /usr/local/lib/libicudata.so.65 /usr/lib/libicudata.so.65

之后再执行初始化操作,我出现如下问题

mysqld: Can't create directory '/var/lib/mysql/' (OS errno 17 - File exists)
2019-12-06T05:48:28.484665Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2019-12-06T05:48:28.484812Z 0 [System] [MY-013169] [Server] /usr/bin/mysqld (mysqld 8.0.18) initializing of server in progress as process 16568
2019-12-06T05:48:28.489066Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2019-12-06T05:48:28.489198Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-12-06T05:48:28.489524Z 0 [System] [MY-010910] [Server] /usr/bin/mysqld: Shutdown complete (mysqld 8.0.18)  Source distribution.

不能够创建,感觉是权限不够的问题,使用sudo权限

sudo mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql

mysql终于成功初始化

2019-12-06T05:50:09.662707Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2019-12-06T05:50:09.662834Z 0 [System] [MY-013169] [Server] /usr/bin/mysqld (mysqld 8.0.18) initializing of server in progress as process 16588
2019-12-06T05:50:12.062984Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 你的密码

初始化成功以后:

sudo systemctl enable mysqld.service  # 允许开机启动
systemctl start mysqld.service  # 启动mysqld服务
systemctl status mysqld.service  # 查看mysqld服务的状态
# 修改密码
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';

终于安装成功了。。。


后记

目的是在学习以下爬虫,所以安装了这些数据库,其实,在docker容器里安装应该会更好一些,可以保持系统干净些。仅作为学习记录,说不定什么时候我又重装系统了呢。


参考文章

https://www.guqing.xyz/archives/mysql-libicu

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值