Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of JDK Environment variable configuration and MySQL and Samba installation in Ubuntu

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you the "Ubuntu Central JDK environment variable configuration and MySQL, Samba installation example analysis", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "Ubuntu Central JDK environment variable configuration and MySQL, Samba installation example analysis" this article.

Configuration of 1.JDK environment variables:

1. Download the latest version of JDK: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-download-346242.html, download x86. bin, do not download-rpm.bin. I put the downloaded jdk-6u25-linux-i586.bin file in the / root/ download directory.

2. To obtain the execution permission of jdk-6u25-linux-i586.bin, the command is as follows: chmod aquix / root/ download / jdk-6u25-linux-i586.bin. If there are no errors, proceed to step 3.

3. Copy: sudo cp / root/ download / jdk-6u25-linux-i586.bin / usr or the directory you want.

4. Go to the copied directory and execute the .bin file. The command is as follows: dudo. / jdk-6u25-linux-i586.bin. After execution, the jdk1.6.0_25 folder will appear in the usr directory. Maybe not. Execute the order again.

5. Set the environment variable: sudo gedit / etc/profile, and add the following command to the open file: (note: change / jdk1.6.0_25 to your own jdk' installation path)

Export JAVA_HOME=/usr/jdk1.6.0_25

Export JRE_HOME=/usr/jdk1.6.0_25/jre

Export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

Export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

6, test, I am restarted, run the command: java-version will show that the version of the jdk installed successfully.

Installation of 2.MySQL

There are three installation methods. The first one is to install online and execute the command sudo apt-get install mysql-server at the terminal.

Enter y enter to install automatically

two。 Install offline packages, take mysql-5.0.45-linux-i686-icc-glibc23.tar.gz as an example.

3. Binary package installation: the environment variables have been automatically configured after installation. You can use the mysql command directly.

Online installation and binary package installation are relatively simple, with emphasis on installing offline packages.

1. Groupadd mysql

2. Mkdir / home/mysql

3. Useradd-g mysql-d / home/mysql mysql

4. Copy mysql-5.0.45-linux-i686-icc-glibc23.tar.gz to / usr/local directory

5. Decompress: tar zxvf mysql-5.0.45-linux-i686-icc-glibc23.tar.gz

6. Ln-s mysql-5.0.45-linux-i686-icc-glibc23 mysql

7. Cd / usr/local/mysql

8. Chown-R mysql.

9. Chgrp-R mysql.

10. Scripts/mysql_install_db-- user=mysql (be sure to execute in the mysql directory, pay attention to the output text, which contains commands to change the root password and start mysql)

11. Set the password for root:. / bin/mysqladmin-u root password 'passw0rd'

Configure and manage msyql:

1. Modify the maximum number of mysql connections: cp support-files/my-medium.cnf. / my.cnf,vim my.cnf, add or modify max_connections=1024

About my.cnf:mysql search the my.cnf:/etc,mysql installation directory and data in the installation directory in the following order. Under / etc are global settings.

two。 Start mysql:/usr/local/mysql/bin/mysqld_safe-- user=mysql &

Check the mysql version: mysqladmin-u root-p version

Note: online installation or binary installation can directly use the following command to start and stop mysql: / etc/init.d/mysql start | stop | restart

3. Stop mysql:mysqladmin-uroot-ppassw0rd shutdown notice that there is no space after u.m.p.

4. Set mysql self-startup: add startup commands to the / etc/rc.local file

5. Allow root to log in remotely:

1) log in to mysql:mysql-u root-p (- p must be available); change the database: use mysql

2) from all hosts: grant all privileges on *. * to root@ "%" identified by "passw0rd" with grant option

3) with grant option; flush privileges from the specified host: grant all privileges on *. * to root@ "192.168.11.205" identified by "passw0rd"

4) enter the mysql library to check whether the data with% host is added: use mysql; select * from user

6. Create database, create user:

1) build the database: create database test1

2) create users, empower: grant all privileges on test1.* to user_test@ "%" identified by "passw0rd" with grant option

3) Delete database: drop database test1

7. Delete permissions:

1) revoke all privileges on test1.* from test1@ "%"

2) use mysql

3) delete from user where user= "root" and host= "%"

4) flush privileges

8. Show all databases: show databases; displays all tables in the library: show tables

9. Remote login mysql:mysql-h ip-u user-p

10. Set the character set (take utf8 as an example):

1) View the current encoding: show variables like 'character%'

2) modify my.cnf and add default-character-set=utf8 under [client]

3) add default-character-set=utf8,init_connect='SET NAMES utf8;' under [server]

4) restart mysql.

Note: only by modifying the my.cnf under / etc can the setting of client take effect, and the setting under the installation directory can only make the setting of server valid.

You can modify / etc/mysql/my.cnf for binary installation.

11. Upgrade old data to utf8 (take latin1 as an example for old data):

1) Export old data: mysqldump-- default-character-set=latin1-hlocalhost-uroot-B dbname-- tables old_table > old.sql

2) Transcoding (Linux and UNIX): iconv-t utf-8-f gb2312-c old.sql > new.sql

It is assumed that the data in the original table is gb2312, or you can remove-f and let iconv automatically determine the original character set.

3) Import: modify new.sql, add a sentence before inserting or modifying statements: "SET NAMES utf8;", and modify all gb2312 to utf8, save.

Mysql-hlocalhost-uroot-p dbname

< new.sql       如果报max_allowed_packet的错误,是因为文件太大,mysql默认的这个参数是1M,修改my.cnf中的值即可(需要重启mysql)。   12. 支持utf8的客户端:Mysql-Front,Navicat,PhpMyAdmin,Linux Shell(连接后执行SET NAMES utf8;后就可以读写utf8的数据了。10.4设置完毕后就不用再执行这句话了)   13. 备份和恢复     备份单个数据库:mysqldump -uroot -p -B dbname >

Dbname.sql

Backup all databases: mysqldump-uroot-p-- all-databases > all.sql

Backup table: mysqldump-uroot-p-B dbname-- table tablename > tablename.sql

Restore database: mysql-uroot-p

< name.sql     恢复表:mysql -uroot -p dbname < name.sql (必须指定数据库)   14. 复制     Mysql支持单向的异步复制,即一个服务器做主服务器,其他的一个或多个服务器做从服务器。复制是通过二进制日志实现的,主服务器写入,从服务器读取。可以实现多个主    服务器,但是会碰到单个服务器不曾遇到的问题(不推荐)。     1). 在主服务器上建立一个专门用来做复制的用户:grant replication slave on *.* to 'replicationuser'@'192.168.0.87' identified by 'iverson';     2). 刷新主服务器上所有的表和块写入语句:flush tables with read lock; 然后读取主服务器上的二进制二进制文件名和分支:SHOW MASTER STATUS;将File和Position的值记录下来。记录后关闭主服务器:mysqladmin -uroot -ppassw0rd shutdown       如果输出为空,说明服务器没有启用二进制日志,在my.cnf文件中[mysqld]下添加log-bin=mysql-bin,重启后即有。     3). 为主服务器建立快照(snapshot)       需要为主服务器上的需要复制的数据库建立快照,Windows可以使用zip格式,Linux和Unix最好使用tar命令。然后上传到从服务器mysql的数据目录,并解压。       cd mysql-data-dir       tar cvzf mysql-snapshot.tar ./mydb       注意:快照中不应该包含任何日志文件或*.info文件,只应该包含要复制的数据库的数据文件(*.frm和*.opt)文件。       可以用数据库备份(mysqldump)为从服务器做一次数据恢复,保证数据的一致性。     4). 确认主服务器上my.cnf文件的[mysqld]section包含log-bin选项和server-id,并启动主服务器:       [mysqld]       log-bin=mysql-bin       server-id=1     5). 停止从服务器,加入server-id,然后启动从服务器:       [mysqld]       server-id=2       注:这里的server-id是从服务器的id,必须与主服务器和其他从服务器不一样。       可以在从服务器的配置文件中加入read-only选项,这样从服务器就只接受来自主服务器的SQL,确保数据不会被其他途经修改。     6). 在从服务器上执行如下语句,用系统真实值代替选项:       change master to MASTER_HOST='master_host', MASTER_USER='replication_user',MASTER_PASSWORD='replication_pwd',         MASTER_LOG_FILE='recorded_log_file_name',MASTER_LOG_POS=log_position;     7). 启动从线程:mysql>

START SLAVE; stops the slave thread: stop slave; (Note: the firewall of the master server should allow port 3306 connections)

Verification: at this time, the data on the master server and the slave server should be the same, insert modification and delete data on the master server will be updated to the slave server, table creation, table deletion and so on.

Installation of 3.samba server

Use the command on the terminal: sudo apt-get install samba4

It can be installed automatically!

These are all the contents of the article "sample Analysis of JDK Environment variable configuration and MySQL and Samba installation in Ubuntu". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report