CentOS7安装配置MySQL并开启远程登录

1、先检查要安装的Linux服务器cglib版本号,命令 strings /lib64/libc.so.6 | grep GLIBC ,查看其是否有相应cglib版本

2、cd /usr/local 下载MySQL5.7
老版本:https://downloads.mysql.com/archives/community/
国内镜像:http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/

3、解压压缩包:tar -xzvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
并且重命名:mv mysql-5.7.23-linux-glibc2.12-x86_64 mysql

4、创建用户组
groupadd mysql
useradd -r -g mysql mysql

5、进入到mysql目录下创建数据目录并赋予权限
创建目录
mkdir data
赋予权限
chown mysql:mysql -R /usr/local/mysql

6、配置my.cnf
vi /etc/my.cnf
datadir改为自己创建的data路径 basedir改为自己安装的mysql路径

[mysqld]
bind-address=0.0.0.0
port=3306
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
socket=/usr/local/mysql/mysql.sock
symbolic-links=0
lower_case_table_names=1
character_set_server=utf8mb4
explicit_defaults_for_timestamp=true

[mysqld_safe]
log-error=/var/log/mysql/mysqld.log
pid-file=/var/log/mysql/mysqld.pid

创建上述配置中的log目录和pid目录 并赋予权限
mkdir /var/log/mysql
mkdir /var/run/mysql
touch /var/log/mysql/mysqld.log
touch /var/log/mysql/mysqld.pid
chown -R mysql:mysql /var/log/mysql/

7、初始化数据库
进入到mysql的bin目录下
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --user=mysql --initialize
目录一定要正确,否则启动不成功
看到最后一行是临时密码:-wPJi*<fz4zX
2021-03-31T15:24:39.285206Z 1 [Note] A temporary password is generated for root@localhost: 7Hjj3+bhpu/v
PS:如果初始化报错error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
就安装:yum install libaio-devel.x86_64

8、启动数据库

把mysql放到本地系统服务中
cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

启动mysql
service mysql start # 启动命令
service mysql status # 查看状态
service mysql stop # 停止命令

9、设置环境变量 开机自启 远程连接
修改配置

vi /etc/profile
在最后一行增加如下配置

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

开机自启
chmod +x /etc/init.d/mysql
chkconfig --add mysql
查看开启
chkconfig --list
如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则键入
chkconfig --level 345 mysqld on

10、 查看初始密码 并更改密码
mysql -u root -h 127.0.0.1 -p
输入密码
进入MySQL,更改密码
SET PASSWORD FOR 'root'@localhost=PASSWORD('XXXXXXXXXXXXXX');

11、开启远程登陆
远程连接设置
登录mysql mysql -u -p
use mysql;
然后查看user表
select user,host from user;
开启远程

GRANT ALL PRIVILEGES ON *.* TO  'root'@'192.168.5.%' IDENTIFIED BY 'XXXpasswordXXX' WITH GRANT OPTION;

%代表所有,也可以写IP,后面是密码,可以和root密码不同
再次查看use mysql,如果root没有%可以使用

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

开启远程权限
flush privileges; # 重载系统权限
exit; # 退出

主要摘自:https://www.icode9.com/content-2-898758.html,一处地方是错的,MySQL开启不了,也有其他地方的
虚拟机测试,本地连接已成功,阿里云应该还要开端口,回头部署……


出现
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
进入bin目录执行
$ ./mysqld_safe --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &

CentOS7 开启FTP并配置登陆

CentOS7 开启FTP并配置登陆
1、安装
yum -y install vsftpd
2、配置VSFTPD
vim /etc/vsftpd/vsftpd.conf
修改几个地方,把#去掉就行,不要全部复制

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode. The vsftpd.conf(5) man page explains
# the behaviour when these options are disabled.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

3、我把默认ftp账户设置密码,也可以自己建立账户,但要指定目录
4、将目录分配给用户 chown ftptest /var/ftp
systemctl start vsftpd 开启
systemctl status vsftpd 状态
systemctl restart vsftpd 重启
5、关闭SELinux
vim /etc/selinux/config ,修改 SELINUX=disabled
然后输入 setenforce 0(我也不记得有没有)
6、启动firewall
systemctl start firewalld.service
加入防火墙
firewall-cmd --permanent --zone=public --add-service=ftp
重启防火墙
firewall-cmd --reload
7、会出现链接不上情况,如下:
[10:16:19] [R] 331 Please specify the password.
[10:16:19] [R] PASS (hidden)
[10:16:26] [R] 530 Login incorrect.
修改vim /etc/pam.d/vsftpd
在auth required pam_shells.so前面加上#
《在auth include system-auth前加上# 这个我没有去掉也可以用,如果不能用就去掉》
8、重启FTP
service vsftpd restart
9、设置开机启动
chkconfig vsftpd on

如果出现:500 OOPS: could not read chroot() list file:/etc/vsftpd/chroot_list
在/etc/vsftpd下新建chroot_list,加入登陆用户的名字
如果出现:500 OOPS: vsftpd: refusing to run with writable root inside chroot()
以在vsftpd的配置文件中增加下列两项中的一项:
allow_writeable_chroot=YES

一个FTP让我弄了快一天时间,中间连接不上也卸载了好几次,文章是摘自好几个地方,有CSDN、cnblogs、jb51等,最后拼凑一起才成功。

linux/CentOS 安装firefox火狐浏览器配置无头模式

1、yum seach firefox
选择64位狐火浏览器安装
whereis firefox
查看安装目录

2、下载geckodriver
https://npm.taobao.org/mirrors/geckodriver/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz
解压放到firefox安装目录
复制一份到/usr/bin ,省去指定路径

3、把firefox安装目录加入环境变量PATH
export PATH="$PATH:/usr/lib64/firefox"

4、测试使用

from selenium import webdriver

options = webdriver.FirefoxOptions()
options.add_argument('-headless')
driver = webdriver.Firefox(firefox_options=options)
driver.get('http://www.baidu.com')
title = driver.title
print('title:'+title)
now_url = driver.current_url
print('URL:' + now_url)
driver.close()

linux安装Python3

卸载Python3.6

whereis python3 |xargs rm -frv

安装Python3.9
1、安装依赖包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel -y

2、下载、解压、进入文件
cd /usr/local
wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz
tar -zxvf Python-3.9.2.tgz
mv Python-3.9.2
cd python3

3、配置路径、编译安装
./configure --prefix=/usr/local/python3
make && make install

4、添加软连接(原来python/pip默认的是2,现在替换成3)
备份:
mv /usr/bin/python /usr/bin/python_back
mv /usr/bin/pip /usr/bin/pip_back
ln -s /usr/local/python3/bin/python3 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

5、加入环境变量
export PATH=$PATH:/usr/local/python3/bin

6、修复 yum 下载(因为 yum 依赖于python2)
vi /usr/libexec/urlgrabber-ext-down
vi /usr/bin/yum
修改首行python为python2

vim安装Python自动补全插件coc.nvim

vim安装自动补全插件coc.nvim
一、vim必须8.0以上
二、安装node.js
curl -sL install-node.now.sh/lts | bash
三、安装plug或vundle插件,以下内容加入插件中

Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
或
Plugin 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}

然后在vim运行:

:PlugInstall

如果coc.vim下载不了,可以进入插件目录git下载到本地在运行PlugInstall
接着运行

:CocInstall coc-json coc-tsserver

四、把以下内容加入.vimrc ,原文地址:https://github.com/neoclide/coc.nvim

" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
" unicode characters in the file autoload/float.vim
set encoding=utf-8

" TextEdit might fail if hidden is not set.
set hidden

" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup

" Give more space for displaying messages.
set cmdheight=2

" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300

" Don't pass messages to |ins-completion-menu|.
set shortmess+=c

" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif

" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
    \ pumvisible() ? "\<C-n>" :
    \ <SID>check_back_space() ? "\<TAB>" :
    \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif

" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
                            \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"

" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>

function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
    call CocActionAsync('doHover')
else
    execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction

" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')

" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)

" Formatting selected code.
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)

" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac  <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf  <Plug>(coc-fix-current)

" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)

" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif

" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)

" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')

" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call     CocAction('fold', <f-args>)

" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')

" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}

" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a  :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e  :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c  :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o  :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s  :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j  :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k  :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p  :<C-u>CocListResume<CR>

五、进入vim输入CocConfig进入配置文件,然后输入

CocInstall coc-pyright

对于Python3自动补全,其他语言参照:https://github.com/neoclide/coc.nvim/wiki/Install-coc.nvim
六、成功后如果弹出警告框在.vimrc加入以下内容

let g:coc_disable_startup_warning = 1