Under Linux install python, mysql

linux install Python3

1.python Download

Enter a command in the terminal:

cd /home
wget http://cdn.npm.taobao.org/dist/python/3.6.5/Python-3.6.5.tgz

Description: The role of this statement is mainly used wget Software (software for beginners Please inform yourself about times, the future will often use) URL to download files from a specified. The format is: 

wget URL address space. The download directory is the current directory, so you need to cd to where you need a place to download the file.

2. Extract the installation files Python3

Enter a command in the terminal:

tar -zxvf Python-3.6.5.tgz 

Description: tar command to unpack the Linux system, this sentence is to extract the files to the folder where the file. If Saturn can then interface to decompress files on the same WIN. The same can be like in the win download the Python source files in the specified folder.

3. Install required to compile the source file compilation environment Python3

yum install -y gcc  
yum install -y zlib*
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel  

Description: This function is very simple to say is yum command. Although linux can also be designated as the official website to download software, software as a win, but there are a number of common and common software will be placed in a specific remote repository can be installed using the yum command. Yum command but also take the initiative to help users solve the problem of software dependent. So if you want to learn linux, then look yum is also necessary. There are also anaconda is similar software.

4. Enter the source files folder Python3

cd Python-3.6.5 /

5. Specify the installation directory

./configure --prefix=/usr/local/python3 --with-ssl
Note: Do not forget the foremost. ""

6. Compile the source file

make

7. formal installation

make install

8. Establish flexible connections

 ln -s /usr/local/python3/bin/python3 /usr/bin/python3 
 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 

Description:
  Many tutorials are the last step, but few sites will tell you why there is the final step. The so-called soft connection is equivalent Shortcuts in the win. You can open the software you want to use by shortcuts. But why should a shortcut on the / usr / bin / it. This involves the environmental variables, and you certainly can not use the last soft connected directly to the / usr / local / python3 / bin added to the environment variables inside, that as you like. But here / usr / bin / is the default already in the environment variable inside, put a shortcut to this folder is equivalent to the indirect Python3 adding environment variables, so that you can open directly in the Python terminal Enter "python3".
   Why not soft link on the desktop it? I think there are two reasons: first, not in the terminal through the command line Python3. Second, not all systems are Linux graphical interface, you may not have the desktop ah, the pro!
  As the last sentence is a software connected to pip. pip3 is Python3 a built-in software. Python is used to install the package. For example, to install Python3 the numpy package. The following command can be used directly in the terminal:

pip3 install requests

Reference links https://blog.csdn.net/weixin_37275456/article/details/80781755

 

Linux install MySQL

Install Mysql database for developers, we are bound to face the problem, its installation process is not complicated, and installation tutorial on the network is also very much, but for the novice, various forms of installation tutorials, and gave novices brought to choose which way to install the problem, and many times not able to follow the tutorial successful installation, the installation process a variety of errors.

Here I record the complete installation process Mysql in a Linux environment, for any errors or omissions, please correct me.

\ Color {# FFA500} {Note:} This document covers installation version after version of mysql-5.7.24,5.7.24, this description does not apply directory location and architecture version of the mysql configuration file has changed after the document, the main reason is that, with this explanation may appear to find without effective after less than a configuration file or configuration.

A pre-installation preparation

1. Check whether mysql has been installed, execute the command

[root@localhost /]# rpm -qa | grep mysql

 

 
 

From the results, it can be seen that we have installed MySQL-libs-5.1.73-5.el6_6.x86_64 , the delete command

[root@localhost /]# rpm -e --nodeps mysql-libs-5.1.73-5.el6_6.x86_64

 

Executing a query command again to see if deleted

[root@localhost /]# rpm -qa | grep mysql

 

 
 

2, all queries Mysql corresponding folder

[root@localhost /]# whereis mysql
mysql: /usr/bin/mysql /usr/include/mysql
[root@localhost lib]# find / -name mysql
/data/mysql
/data/mysql/mysql

 

Delete the relevant file or directory

[root@localhost /]#  rm -rf /usr/bin/mysql /usr/include/mysql /data/mysql /data/mysql/mysql 

 

Verify that the deletion is complete

[root@localhost /]# whereis mysql
mysql:
[root@localhost /]# find / -name mysql
[root@localhost /]# 

 

3, check the mysql user groups and users exists, if not, create

[root@localhost /]# cat /etc/group | grep mysql
[root@localhost /]# cat /etc/passwd |grep mysql
[root@localhost /]# groupadd mysql
[root@localhost /]# useradd -r -g mysql mysql
[root@localhost /]# 

 

4, is the official website to download from Mysql installation package for Linux

Download Command:

[root@localhost /]#  wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

 

Also go directly to mysql official website to choose other versions to download.

 
 

Two assembling Mysql

1, in the implementation of wget find Mysql installation package directory under your command or upload directory: MySQL-5.7.24-Linux-glibc2.12-x86_64.tar.gz
performs decompression command:

[root@localhost /]#  tar xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
[root@localhost /]# ls
mysql-5.7.24-linux-glibc2.12-x86_64
mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz

 

解压完成后,可以看到当前目录下多了一个解压文件,移动该文件到/usr/local/mysql
执行移动命令:

[root@localhost /]# mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql

 

2、在/usr/local/mysql目录下创建data目录

[root@localhost /]# mkdir /usr/local/mysql/data

 

3、更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限

[root@localhost /]# chown -R mysql:mysql /usr/local/mysql
[root@localhost /]# chmod -R 755 /usr/local/mysql

 

4、编译安装并初始化mysql,务必记住初始化输出日志末尾的密码(数据库管理员临时密码)

[root@localhost /]# cd /usr/local/mysql/bin
[root@localhost bin]# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

 


补充说明:

此时可能会出现错误:

 
 

出现该问题首先检查该链接库文件有没有安装使用 命令进行核查

运行命令后发现系统中无该链接库文件

[root@localhost bin]#  yum install  libaio-devel.x86_64

 

安装成功后,继续运行数据库的初始化命令,此时可能会出现如下错误:

 
 

执行如下命令后,再次运行数据库的初始化命令:

[root@localhost bin]#  yum -y install numactl

 


5、运行初始化命令成功后,输出日志如下:

 
 

记录日志最末尾位置root@localhost:后的字符串,此字符串为mysql管理员临时登录密码。

6、编辑配置文件my.cnf,添加配置如下

[root@localhost bin]#  vi /etc/my.cnf

[mysqld]
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
#表名大小写不明感,敏感为
lower_case_table_names=1

 

7、启动mysql服务器

[root@localhost /]# /usr/local/mysql/support-files/mysql.server start

 

显示如下结果,说明数据库安装成功

 
 

如果出现如下提示信息

Starting MySQL... ERROR! The server quit without updating PID file

 

查看是否存在mysql和mysqld的服务,如果存在,则结束进程,再重新执行启动命令

#查询服务
ps -ef|grep mysql
ps -ef|grep mysqld

#结束进程
kill -9 PID

#启动服务
 /usr/local/mysql/support-files/mysql.server start

 

 
 

8、添加软连接,并重启mysql服务

[root@localhost /]#  ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 
[root@localhost /]#  ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost /]#  service mysql restart

 

9、登录mysql,修改密码(密码为步骤5生成的临时密码)

 
 

10、开放远程连接

mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;

 

 
 

11、设置开机自动启动

1、将服务文件拷贝到init.d下,并重命名为mysql
[root@localhost /]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
2、赋予可执行权限
[root@localhost /]# chmod +x /etc/init.d/mysqld
3、添加服务
[root@localhost /]# chkconfig --add mysqld
4、显示服务列表
[root@localhost /]# chkconfig --list

 

解决MySQL本地可以连接,远程连接不上问题


1.网络或防火墙问题

(1)检查网络直接ping你的远程服务器,ping 182.61.22.107,可以ping通说明网络没问题

(2)看端口号3306是不是被防火墙挡住了,telnet 182.61.22.107 3306

下图这样就是防火墙挡住了3306端口不允许访问

配置防火墙,开启3306端口

vi / etc / sysconfig / iptables // firewall configuration 

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT // through port 3306 allows 

service iptables restart // reboot the firewall

Configuration is as follows:

2.MySQL Configuration

After you have found the firewall is turned on or telnet fails, I go, being given as follows:

The reason here is because your database only allows the root user to log on locally, you can set up a user with the address to allow access

(1) view the user access to the database table

mysql -u root -p // Log database 

use mysql // enter the mysql database 

select Host, User from user; // Check ip can access the database

The results are as follows:

(2) setting can be accessed ip

update user set host = '%' where host = 'localhost'; // allow all access to 

flush privileges; // refresh the effect

Of course, only be allowed to access some of the ip, ip or segment access: the GRANT ALL PRIVILEGES the ON  * * the TO.  'Root' @ '* 182.61 *..' The IDENTIFIED BY  'password' the WITH the GRANT the OPTION; // allow root account segment 182.61 log in

 

 

 

 

Guess you like

Origin www.cnblogs.com/ouyang99-/p/12192381.html