解决Debian下启动MySQL报61 Connection refused

1.问题说明

Debian-9.12.1-AMDx64

使用sudo apt-get install mariadb-server mariadb-client在线非编译安装方式

简述:该问题出现一般是没有开放账号权限给外 IP 访问

2.解决思路

在伺服器键入设置mysql_secure_installation重设规则,前提是确认好是否安装到位 MySQLdpkg -l | grep mysql,重设规则这里跳过不需设置 root 密码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n
... skipping.
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] y
... 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] n
... skipping.
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 test database...
... Success!
- Removing privileges on test database...
... 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!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

重启服务systemctl restart mariadb观察是否正常。

若不正常继续键入netstat -tap | grep mysql确认 MySQL 是否在 listen 状态

正常继续键入mysql -u root -p在本地登陆 MySQL,若忘记密码可以去sudo cat /etc/mysql/debian.cnf查看,以下完成设置远程访问的权限

1
2
3
4
5
6
use mysql;
select user,Host from user;
update user set Host='%' where user='root';
grant all privileges on *.* to 'root'@'%' identified by '密码' with grant option;
flush privileges;
exit;

重启服务,观察是否正常。

若还是不正常,继续键入cd /etc/mysql/mysql.conf.d查看配置文件是不是正常对外 IP 访问vim 50-server.cnf

发现bind-address 配置项错误,理应改成 0.0.0.0

保存后,重启服务,再观察是否正常。

SVN/Git报错问题汇总

Q: Please execute the ‘Cleanup’ command

下载sqlite3工具,解压缩 sqlite3.exe 程序至仓库根目录,然后 cmd 命令行工具,键入

1
2
sqlite3.exe .svn/wc.db "select * from work_queue" #该命令可以查看当前挂起的svn操作
sqlite3.exe .svn/wc.db "delete from work_queue" #该命令可以删除当前挂起的svn操作

最后重新 cleanup 即可修复

Q: clone 项目的时候git@github.com: Permission denied (publickey)

这个错误通常是因为你没有在本地机器上与 GitHub 账户关联的有效 SSH 密钥,因此无法连接到 GitHub 账户,你需要创建个凭证链接至 Github

有需要提醒你,GitHub 在境内接近 block 状态,你需要些加速手段,如环境变量 http_proxy[ghproxy.com/gitclone.com]或者自有加速$ git config –global http.https://github.com.proxy socks5://127.0.0.1:17890

下面以 Windows 做事例,键入 cmd

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

按顺序分别输入文件保存路径(默认是 C:\Users.ssh\id_rsa.pub)、密码和确认密码,完成后将 id_rsa.pub 打开,复制所有内容至自己的 GitHub 账户,打开”Settings”页面,选择”SSH and GPG keys”内。

键入 git bash 打开,将生成的密钥添加到 ssh-agent

ssh-add ~/.ssh/id_rsa

最后,检查是否已关联了正确的 SSH 密钥

ssh-add -l

Ubuntu食用相关

Q:执行 yarn install 出错 Yarn install command error No such file or directory: ‘install’

1
2
3
4
5
6
sudo apt remove cmdtest
sudo apt remove yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn

Q:Debian11 服务器系统默认不存在 sudo 命令的解决办法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
apt-get install vim
vim /etc/apt/sources.list

#!编辑注释所有,添加以下
deb http://mirrors.aliyun.com/debian/ bullseye main contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye main contrib
deb http://mirrors.aliyun.com/debian/ bullseye-updates main contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-updates main contrib
deb http://mirrors.aliyun.com/debian/ bullseye-backports main contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-backports main contrib
deb http://mirrors.aliyun.com/debian/ bullseye-proposed-updates main contrib
deb-src http://mirrors.aliyun.com/debian/ bullseye-proposed-updates main contrib

apt-get update
apt-get install sudo

Q:安装 Nodejs

1
2
3
4
5
6
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v

#!卸载如下
sudo apt-get remove nodejs

Q:食用 yum 出现 except KeyboardInterrupt, e:或 except OSError,

1
2
3
4
5
6
7
8
whereis python
#修改yum配置文件,将python版本指向以前的旧版本
# vi /usr/bin/yum
#!/usr/bin/python2.7

#修改urlgrabber-ext-down文件,更改python版本
# vi /usr/libexec/urlgrabber-ext-down
#!/usr/bin/python2.7