这篇文章主要介绍“Ubuntu中如何安装JDK与MySQL”,在日常操作中,相信很多人在Ubuntu中如何安装JDK与Mysql问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Ubuntu中如何安装JDK与Mysql”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
专注于为中小企业提供成都网站设计、做网站、成都外贸网站建设公司服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业牟定免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了近1000家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
一、安装jdk
step1.下载oraclejdk
step2. 解压
step3. 加入环境变量
具体操作如下:
lemon@ubuntu:~$ cd ~/download/
lemon@ubuntu:~/download$ wget https://download.oracle.com/otn-pub/java/jdk/13.0.2+8/d4173c853231432d94f001e99d882ca7/jdk-13.0.2_linux-x64_bin.tar.gzlemon@ubuntu:~/download$ tar vxf jdk-8u191-linux-x64.tar.gz
lemon@ubuntu:~/download$ ls #查看当前目录下的文件
jdk1.8.0_191 jdk-8u191-linux-x64.tar.gz
lemon@ubuntu:~/download$ sudo mv jdk1.8.0_191/ /usr/local/jdk1.8/ #将jdk1.8.0_191文件夹移动到/usr/local/下并重命名为jdk1.8
lemon@ubuntu:~/download$ sudo vim /etc/profile #编辑环境变量
在环境变量末尾加入如下内容:
export java_home=/usr/local/jdk1.8
export jre_home=${java_home}/jre
export classpath=.:${java_home}/lib:${jre_home}/lib
export path=.:${java_home}/bin:$path
保存后重新加载环境变量,使生效:
lemon@ubuntu:~/download$ source /etc/profile #刷新环境变量,使生效
lemon@ubuntu:~$ java -version#输入java -version,如显示以下信息,则jdk安装成功
java version "1.8.0_191"
java(tm) se runtime environment (build 1.8.0_191-b12)
java hotspot(tm) 64-bit server vm (build 25.191-b12, mixed mode)
二、安装mysql
step1. 安装mysql并配置
step2. 创建数据库与表
由于在安装ubuntu系统时,本人选择了安装lamp服务,所以mysql已安装完成,仅需设置即可启用。
测试是否安装:
lemon@ubuntu:~$ mysql #输入mysql,如出现以下提示,说明已安装mysql
error 1045 (28000): access denied for user 'lemon'@'localhost' (using password: no)
如未安装:
lemon@ubuntu:~$ sudo apt-get install mysql-server
lemon@ubuntu:~$sudo apt isntall mysql-client
lemon@ubuntu:~$sudo apt install libmysqlclient-dev
如已安装:
lemon@ubuntu:~$ sudo mysql_secure_installation
两者都会进入mysql设置过程,具体设置内容如下:
#1
validate password plugin can be used to test passwords...
press y|y for yes, any other key for no: n(不启用弱密码检查)
#2
please set the password for root here...
new password: (设置root密码)
re-enter new password: (重复输入)
#3
by default, a mysql installation has an anonymous user,
allowing anyone to log into mysql without having to have
a user account created for them...
remove anonymous users? (press y|y for yes, any other key for no) : y(不启用匿名用户)
#4
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? (press y|y for yes, any other key for no) : y (不允许root远程登陆)
#5
by default, mysql comes with a database named 'test' that
anyone can access...
remove test database and access to it? (press y|y for yes, any other key for no) : n
#6
reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
reload privilege tables now? (press y|y for yes, any other key for no) : y (立刻刷新权限表)
all done!
接下来进入进入mysql进行操作:
#最新版的mysql安装之后无法使用密码进行登陆,需要sudo登录修改登录方式
lemon@ubuntu:~$ sudo mysql -uroot -p
enter password: (空密码)
mysql>
mysql>update mysql.user set authentication_string=password('lemon'), plugin='mysql_native_password' where user='root';
mysql> flush privileges;
mysql>exitlemon@ubuntu:~$ sudo service mysql restart
lemon@ubuntu:~$ mysql -u root -p
enter password: (上一步设置的密码,password括号内的)
mysql>create database nutch;
mysql>use nutch
mysql> create table `webpage` (
`id` varchar(767) not null,
`headers` blob,
`text` mediumtext default null,
`status` int(11) default null,
`markers` blob,
`parsestatus` blob,
`modifiedtime` bigint(20) default null,
`score` float default null,
`typ` varchar(32) character set latin1 default null,
`baseurl` varchar(767) default null,
`content` longblob,
`title` varchar(2048) default null,
`reprurl` varchar(767) default null,
`fetchinterval` int(11) default null,
`prevfetchtime` bigint(20) default null,
`inlinks` mediumblob,
`prevsignature` blob,
`outlinks` mediumblob,
`fetchtime` bigint(20) default null,
`retriessincefetch` int(11) default null,
`protocolstatus` blob,
`signature` blob,
`metadata` blob,
`batchid`varchar(767)default null,
primary key (`id`)
) engine=innodb
row_format=compressed
default charset=utf8mb4;
mysql>exit
*最新版本默认情况下,mysql是不允许远程登录的,如需远程访问需要做一些修改:
lemon@ubuntu:~$sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#将bind-address = 127.0.0.1注释掉,重启mysql服务
lemon@ubuntu:~$sudo service mysqld start
接下来就可以通过navicat等软件,在其他计算机访问数据库了。
到此,关于“Ubuntu中如何安装JDK与Mysql”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!